Questions tagged [linq-to-entities]

This tag is for questions about LINQ to Entities, which means LINQ queries using the ADO.NET Entity Framework. Note that this is different than LINQ to SQL or other LINQ providers.

This tag is for questions about LINQ to Entities, which means LINQ queries using the ADO.NET Entity Framework. Note that this is different than LINQ to SQL or other LINQ providers.

Related Links

6860 questions
3
votes
2 answers

How to check if IQueryable has OrderBy applied before before attempting Skip() and Take()

I am trying to build an extension method that will Paginated a query. But in order to avoid exception: System.NotSupportedException was unhandled by user code Message=The method 'Skip' is only supported for sorted input in LINQ to Entities. The…
zam6ak
  • 7,229
  • 11
  • 46
  • 84
3
votes
0 answers

Do 2 queries need to be submitted to the database to get total count and paged section using EF / Linq to Entities?

Possible Duplicate: Better way to query a page of data and get total count in entity framework 4.1? When implementing pagination using EF / LINQ to entities, I am familiar with using Skip() and Take() to decide which paginated section to display.…
3
votes
1 answer

Complex LINQ or EF query

I have the following 3 classes. A workflow configuration has one brand and one workflowtype. I need one method in linq or EF that gets me all the brands of existing workflowconfiguration and another method that gets me all the brands of non…
3
votes
1 answer

Entity Framework: perform a query on a linking table / many to many relationship

I am trying to perform a query using linq to entities to that an entity/table doesn't contain the same values before I update it. The structure of the database is as follows: Users User_IPAddresses IPAddresses ----- …
Calanus
  • 25,619
  • 25
  • 85
  • 120
3
votes
5 answers

Multiple rows update without select

An old question for Linq 2 Entities. I'm just asking it again, in case someone has came up with the solution. I want to perform query that does this: UPDATE dbo.Products WHERE Category = 1 SET Category = 5 And I want to do it with Entity Framework…
Admir Tuzović
  • 10,997
  • 7
  • 35
  • 71
3
votes
2 answers

Selecting part of a single entity without retrieving the entire entity

I want to get a single property(blob) from a single entity (by Id). I have: context.References .Single(r => r.ID == id) .Blob; This strikes me as inefficient, because I'm getting the entire Reference, only to discard everything except the…
Matthew Fotzler
  • 630
  • 1
  • 6
  • 13
3
votes
2 answers

Entity framework - select by multiple conditions in same column - referenced table

Example scenario: Two tables: order and orderItem, relationship One to Many. I want to select all orders that have at least one orderItem with price 100 and at least one orderItem with price 200. I can do it like this: var orders = (from o in…
quin16
  • 515
  • 2
  • 8
  • 15
3
votes
2 answers

How to check if a char array contains every element in another char array?

Possible Duplicate: LINQ: Check whether an Array is a subset of another I am trying to determine if there is a way to use LINQ to find if every element in a subset array is in a superset array. For example with this…
Abe Miessler
  • 82,532
  • 99
  • 305
  • 486
3
votes
2 answers

Linq select Distinct by two properties

I have a fairly complex LINQ query that joins several tables, and selects a new anonymous type that is three IEnumerable's {Users, JobProviders, Jobs}. It returns an IQueryable to maintain deferred execution, which eliminates DistintBy from this…
Kyeotic
  • 19,697
  • 10
  • 71
  • 128
3
votes
2 answers

Convert.Int64 Is Not Reconized LINQ To Entities

I am getting the following exception: LINQ to Entities does not recognize the method 'Int64 ToInt64(System.String)' method, and this method cannot be translated into a store expression. I had long.Parse(ProjectID.ToString()) and I see the suggestion…
Nick LaMarca
  • 8,076
  • 31
  • 93
  • 152
3
votes
2 answers

Entity Framework + LINQ Slowness vs String Query Speed?

I've inherited a C# / ASP.NET MVC / Entity Framework project with some slowness. There's not a lot of data in the DB but calls to .Include() were causing slowdowns. However, I found something very strange. I have a 2k row table with just numbers…
Alexandru Petrescu
  • 3,449
  • 2
  • 23
  • 23
3
votes
1 answer

Entity Framework: Can't use "Contains" with property on another object

Sorry for the bad title...This one is probably best explained with an example: void Main() { IQueryable toLinkTo = context.ClassAs.Where(a => a.Name == "SomeName"); var queryToExecute = context.ClassBs.Where(cb => toLinkTo.Select(ca…
Ocelot20
  • 10,510
  • 11
  • 55
  • 96
2
votes
1 answer

How to format data with LINQ to Entities in the following format?

Using LINQ can I get the data from the table into the format shown directly below? Can LINQ perform this type of formating or should I loop through the results to format? Format I'm trying to get data into: dau gmu population …
KeelRisk
  • 749
  • 1
  • 9
  • 27
2
votes
3 answers

Dynamic new field in LINQ

Is this possible to create new {variable = x.something} and specify variable name dynamically? For example: var name = "dynamicName"; var result = context.select(x=> new {name.ToString() = x.something }) In this way we would have a list where…
kosnkov
  • 5,609
  • 13
  • 66
  • 107
2
votes
3 answers

Load Records From EF Data Model in Custom/Predefined Order Using LINQ

I have a comma delimited list of record id's: string = "2207,117,90,2168,120,118,113,112,17" I need to be able to load the records those id's are associated with in the position that they are in that string. Here is the code I am using to get my…
Jared
  • 2,443
  • 8
  • 26
  • 40