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
27
votes
2 answers

Are Find and Where().FirstOrDefault() equivalent?

I have been using the Find(id) extension method with collections in Entity Framework 5. However, many of the examples I see use Where(s => s.Id == 1), to which I added FirstOrDefault() to get the object instead of a collection. Is this a style…
27
votes
8 answers

ADO.NET Entity Connection String for Multiple Projects

I am using multiple layer project where the DataModel hosts the ADo.NET Entity model and DataAccess layer does the validation. However everytime I get a error like this The specified named connection is either not found in the configuration, not…
27
votes
5 answers

The version of SQL Server in use does not support datatype datetime2?

An error occurred while executing the command definition. See the inner exception for details. bbbbInnerException:aaaa System.ArgumentException: The version of SQL Server in use does not support datatype 'datetime2'. at…
26
votes
4 answers

ASP.NET MVC 2.0 Implementation of searching in jqgrid

Hi I am trying to use the single column search in jqgrid using MVC 2 IN .NET (VS 2008) this is the code I have so far but I need an example to match it with or a tip of what I am missing jQuery("#list").jqGrid({ url: '/Home/DynamicGridData/', …
Sue
  • 445
  • 1
  • 11
  • 25
26
votes
5 answers

Get distinct records using linq to entity

Hi I'm using linq to entity in my application. I need to get distinct records based on one column value "Name" So I have a table similar like you can see below: (User) ID Name Country DateCreated I need to select all this items but uniques based on…
Boommer
  • 261
  • 1
  • 3
  • 3
26
votes
1 answer

LINQ to Entities does not recognize the method 'System.DateTime AddSeconds(Double)' method, and this method cannot be translated into

I receive this error on base {System.SystemException} = {"LINQ to Entities does not recognize the method 'System.DateTime AddSeconds(Double)' method, and this method cannot be translated into a store expression."} on this code var…
GibboK
  • 71,848
  • 143
  • 435
  • 658
26
votes
4 answers

Entity Framework 4 - What is the syntax for joining 2 tables then paging them?

I have the following linq-to-entities query with 2 joined tables that I would like to add pagination to: IQueryable data = from inventory in objContext.ProductInventory join variant in objContext.Variants on…
NightOwl888
  • 55,572
  • 24
  • 139
  • 212
25
votes
4 answers

Entity Framework 4 / Linq: How to convert from DateTime to string in a query?

I have the following query: from a in Products select new ProductVM { id = a.id, modified = a.modified.ToString() } Which gives me an error of: LINQ to Entities does not recognize the method 'System.String…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
25
votes
4 answers

Entity Framework - Stop Lazy Loading Related Entities On Demand?

I have Entity Framework set up and it works fine most of the time I need it. I have a structure like so public partial class Topic : Entity { public Guid Id { get; set; } public string Name { get; set; } public DateTime CreateDate { get;…
YodasMyDad
  • 9,248
  • 24
  • 76
  • 121
24
votes
13 answers

LINQ to Entities - where..in clause with multiple columns

I'm trying to query data of the form with LINQ-to-EF: class Location { string Country; string City; string Address; … } by looking up a location by the tuple (Country, City, Address). I tried var keys = new[] { new {Country=…,…
millimoose
  • 39,073
  • 9
  • 82
  • 134
24
votes
5 answers

Casting to a derived type in a LINQ to Entities query with Table Per Hierarchy inheritance

I have a LINQ to entities model with Table Per Hierarchy inheritance. I have a query over the base type, and I want to do specific type-dependent logic. For example: IQueryable base = ... // this works fine var result = base.Select(b => b…
ChaseMedallion
  • 20,860
  • 17
  • 88
  • 152
24
votes
6 answers

Updating Entity Framework Model

I have just started using EF and found it cool, but I ran into a problem, Problem: I changed my DB schema of a column inside the table User, It was Varbinary(50) previously I then changed it into VarChar(50), and then inside the MyModel.edmx…
23
votes
6 answers

How can I attach an Entity Framework object that isn't from the database?

I have a complete separation of my Entity Framework objects and my POCO objects, I just translate them back and forth... i.e: // poco public class Author { public Guid Id { get; set; } public string UserName { get; set; } } and then I have an…
sontek
  • 12,111
  • 12
  • 49
  • 61
23
votes
3 answers

Multiple SQL aggregate functions in a single Linq-to-Entities query

In SQL you can express multiple aggregates in a single database query like this: SELECT MIN(p.x), MAX(p.x), MIN(p.y), MAX(p.y) FROM Places p JOIN Logs l on p.Id = l.PlaceId WHERE l.OwnerId = @OwnerId Is it possible to do an equivalent thing…
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742
23
votes
2 answers

Linq OrderBy breaks with navigation property being null

Working with four tables. Users -> has basic user info including a userid and a departmentid (int) Groups -> basic group info including a groupid GroupsMembers -> table that has the relationship between a group and it's members, many to many…
Steph
  • 409
  • 2
  • 8
  • 14