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

Simple Automapper Example

I am having a hard time to understand how to map certain objects. Please answer some questions about this simple example. Example code class User { private int id; private string name; } class Group { private int id; private string…
David
  • 965
  • 3
  • 12
  • 24
36
votes
4 answers

How to do a Bulk Insert -- Linq to Entities

I cannot find any examples on how to do a Bulk/batch insert using Linq to Entities. Do you guys know how to do a Bulk Insert?
Luke101
  • 63,072
  • 85
  • 231
  • 359
36
votes
6 answers

How to tell if an IEnumerable is subject to deferred execution?

I always assumed that if I was using Select(x=> ...) in the context of LINQ to objects, then the new collection would be immediately created and remain static. I'm not quite sure WHY I assumed this, and its a very bad assumption but I did. I often…
Simon_Weaver
  • 140,023
  • 84
  • 646
  • 689
35
votes
7 answers

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

I have a method: public DzieckoAndOpiekunCollection GetChildAndOpiekunByFirstnameLastname(string firstname, string lastname) { DataTransfer.ChargeInSchoolEntities db = new DataTransfer.ChargeInSchoolEntities(); DzieckoAndOpiekunCollection…
netmajor
  • 6,507
  • 14
  • 68
  • 100
34
votes
4 answers

The right way to insert multiple records to a table using LINQ to Entities

As many of us have done, I set up a simple loop to add multiple records from a databse. A prototypical example would be something like this: Method I: // A list of product prices List prices = new List { 1, 2, 3 }; NorthwindEntities…
seebiscuit
  • 4,905
  • 5
  • 31
  • 47
34
votes
3 answers

Can't get EntityFunctions.TruncateTime() to work

I am using Entity Framework Code First. Using LINQ to Entity I want to grab a record based on a DateTime value. Here is my current code: /// /// A method to check and see if the Parsed Game already exists on the /// database. If Yes, then…
J86
  • 14,345
  • 47
  • 130
  • 228
34
votes
2 answers

Include Grandchildren in EF Query

Given the object hierarchy public class Parent { public int Id { get; set; } public virtual Child Child { get; set; } } public class Child { public int Id { get; set; } public virtual GrandChild GrandChild { get; set; } } public…
Eric J.
  • 147,927
  • 63
  • 340
  • 553
34
votes
5 answers

Linq when using GroupBy, Include is not working

include matchparticipants is not working. It always says Null when I debug. But when I put the GroupBy in comment it works fine. I am using Entity framework 4.3.1 with code-first. Entities: public class Match { [ScaffoldColumn(false)] …
Bart
  • 363
  • 1
  • 3
  • 6
33
votes
5 answers

linq to entities vs linq to objects - are they the same?

I usually use the term entity to represent a business data object and in my mind, the linq to entities and linq to objects were the same. Is that not correct?
Alex J
  • 1,547
  • 2
  • 26
  • 41
33
votes
3 answers

Is there a way to export the .edmx diagram from VS2008 to Visio?

Some people want to see the DB structure and dont have VS, is there a way to do this? Or any other way to export it outside of a screencapture (it is a huge diagram). Thank you.
naspinski
  • 34,020
  • 36
  • 111
  • 167
33
votes
2 answers

How to do a SQL "Where Exists" in LINQ to Entities?

I really want to do something like this: Select * from A join B on A.key = B.key join C on B.key = C.key -- propagated keys where exists (select null from B where A.key = B.key and B.Name = "Joe") and exists (select null from C where B.key =…
Zachary Scott
  • 20,968
  • 35
  • 123
  • 205
32
votes
1 answer

Strange LINQ To Entities Exception

I am using a LINQ statement that selects from various tables information I need to fill some Post / Post Comment style records. I'm getting a funny exception saying that the object must implement IConvertible when I try to iterate the record set.…
SilverX
  • 1,509
  • 16
  • 18
32
votes
2 answers

Joining tables using more than one column in Linq To Entities

Every single example of joins in Linq to Entities involves only one column in the on clause. What is the syntax if I need 2 or more columns to make the join work? I would need an example for Linq to Entities Query Expressions and Method Based also,…
Pascal
  • 2,944
  • 7
  • 49
  • 78
32
votes
4 answers

Implicit convert List to List

I am using Linq to Entities. Have an entity "Order" which has a nullable column "SplOrderID". I query my Orders list as List lst = Orders.where(u=> u.SplOrderID != null).Select(u => u.SplOrderID); I understand it is because SplOrderID is a…
Manvinder
  • 4,495
  • 16
  • 53
  • 100
31
votes
11 answers

How to use SQL 'LIKE' with LINQ to Entities?

I have a textbox that allows a user to specify a search string, including wild cards, for example: Joh* *Johnson *mit* *ack*on Before using LINQ to Entities, I had a stored procedure which took that string as parameter and did: SELECT * FROM Table…
esac
  • 24,099
  • 38
  • 122
  • 179