Questions tagged [linq-method-syntax]

49 questions
0
votes
2 answers

Error: IAsyncEnumerable cannot be used for parameter of type IEnumerable on Entity framework

I've got these two LINQ expressions. I'm using Entity Framework. The only difference is the position of the items on the list of CardIds. The first example returns the AdditionalCards that comes from "MemberAdditionalCards" first and then it adds…
0
votes
1 answer

LINQ to XML selecting elements similar to SQL IN clause

I have some XML that contains Payment information including details on the Invoices the payments are being applied to. I would like to use LINQ to XML to gather only those payments that are applied to certain invoices (111,222,333) for example. If…
webworm
  • 10,587
  • 33
  • 120
  • 217
0
votes
0 answers

Condition in ternary operator is being ignored within a 'Where' method. Is there another better approach to query?

I'm trying to implement a method to retrieve data from database with EF and Linq method syntax. The method has 5 parameters (four List and one string), each parameter must work as a filter for the query result. Using a ternary operator within…
0
votes
2 answers

Issues with .NET Linq statement

Linq and Query's syntax is one of my weakest skills. I'm having issues with getting the desired result. I have two tables/ collections. One is filled with DocumentTypes, the other with Notifications. These are the fields they hold that matter, I…
Robin
  • 2,704
  • 7
  • 30
  • 47
0
votes
0 answers

LINQ Generic GroupBy And SelectBy With Method Syntax

I'm trying to make it generic but didn't succeed. It doesnt get related User entity. return from transactions in context.Transaction where transactions.Date.Month == date.Month && transactions.Date.Year == date.Year join users in…
0
votes
2 answers

how to group based on dates then hours?

I have a table which stores visit days in a fair. for example visitors visit fairs from day "a" to day "b". I wrote a query winch groups based on visit date. but it gives me "how many visits per day". here is my query: var visitDays = from v in…
Afsaneh Daneshi
  • 340
  • 4
  • 17
0
votes
1 answer

Getting multiple different values from same table LINQ

I want to retrieve multiple values from single table based on multiple conditions using only one LINQ query. my table looks like: ArticleId (int) ArticleName (string) CreatedDate (datetime) ArticleType (string) Views (int) I want to retrieve: top…
0
votes
1 answer

How to improve LINQ query

I am working on an application where a user can filter records by categories. A record must have 1 but can have many categories. (1-*) The question I have is, What can I do to improve this search? It currently runs at about an O(n^3) for the…
Ingenioushax
  • 718
  • 5
  • 20
0
votes
2 answers

GroupBy with Linq to entities query

I have following classes: public class OrderItem { public int Id { get; set; } public ICollection NominalRoutings{ get; set; } } public class NominalRouting { public int Id { get; set; } public DateTime PlanedDate…
Masoud
  • 8,020
  • 12
  • 62
  • 123
0
votes
0 answers

Linq method syntax counterpart for Linq query syntax

I have a collection of orders. Each order has a subcollection of OrderItems. Now I have a Linq query syntax that works: var ordersProjection = from order in orders from oi in order.OrderItems where oi.Quantity >…
Andi
  • 57
  • 4
0
votes
1 answer

Entity Framework 6 - Outer Joins and Method Syntax Queries

I'm trying to re-write the following SQL LEFT OUTER JOIN query using Entity Framework 6: select tblA.*, tblB.* from dbo.TableA tblA left outer join dbo.TableB tblB on tblA.Student_id=tblB.StudentId and tblA.other_id=tblB.OtherId where tblB.Id…
Mass Dot Net
  • 2,150
  • 9
  • 38
  • 50
0
votes
1 answer

How to return custom objects using Except

I'm using ASP.NET MVC, C# and SQL Server. I want to get a list of cars that are available for rent within a certain date, ie. not already rented out. What I got now is something like taking all the cars from the cars table, except the ones that…
CAR1980
  • 33
  • 5
0
votes
3 answers

Cannot implicitly convert type 'System.Collections.Generic.List' to 'System.Linq.IQueryable'

This query is being compiled without errors: var _entityList = context.customer .Join(context.applications, cust => cust.cust_id, app => app.cust_id, (cust, app) => new {…
Khadim Ali
  • 2,548
  • 3
  • 33
  • 61
0
votes
1 answer

The cast to value type 'Decimal' failed because the materialized value is null

I have the following code : public ViewResult Stock(Guid id) { // Get the product form the database var product = productRepository.GetById(id); var viewModel = new ProductStockViewModel() { …
Marc
  • 2,023
  • 4
  • 16
  • 30
0
votes
2 answers

Entity Framework Simple Filter by NavigationProperty using LINQ Methods

I am learning EF and LINQ to EF. We are using LINQ Methods and not LINQ Expressions. I am trying to do a very simple query from my 2 entities. NavigationGroup is a one to many relation to NavigationGroupLocation. The Navigation Property in…
Jared
  • 2,443
  • 8
  • 26
  • 40