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
1 answer

Why when I use GroupBy() in my LINQ to Entities query, the navigation property in the result is null?

Edited: I'm developing an application with EF code first, I have a method that return a Dictionary: public Dictionary GetLastDocumentStationHistoryListOfDocuments(string criteria) { Dictionary
Masoud
  • 8,020
  • 12
  • 62
  • 123
3
votes
2 answers

Best Practices: Redundant data or multiple joins?

Suppose you have the following tables: Orders, Customers, Events, Lines, and LineAssignments. The only table that I can modify is the LineAssignments table. Event 1 <---> * Orders Customer 1 <---> * Orders Order 1 <---> * LineAssignments Line 1…
Jamie Lester
  • 848
  • 9
  • 20
3
votes
2 answers

.NET LINQ to Entities base where clause for generic Type

I am using Entity Framework to access my domain models, all of which implement an interface (IPublishable) that specifies properties to indicate whether an item has been published. When accessing items from the front end I always want to filter out…
JDandChips
  • 9,780
  • 3
  • 30
  • 46
3
votes
2 answers

adding new methods to LINQ to Entities

Is there any way to define the SQL conversion component for additional functions to Linq2Entities. For example: myQuery.Where(entity => entity.Contains('foo', SearchFlags.All)) Ideally I am looking for something that doesn't require editing and…
Seph
  • 8,472
  • 10
  • 63
  • 94
3
votes
1 answer

Combine select clauses in linq to entities with anonymous types

How can i combine select clause in linq to entities in order to project into an anonymous type? Assume that I have these entities: public class Address { public string City { get; set; } public int ZipCode { get; set; } //other…
3
votes
3 answers

LINQ to Entities - parse / filter object collection

I am trying to filter a list of users from my database. When I run this LINQ to Entity command, it works as I had hoped. It returns all users, filtered by whatever is in txtFilterBy_UserName : (notice that I am accessing the db table directly. …
wotney
  • 1,039
  • 3
  • 21
  • 34
3
votes
1 answer

Executing Expression ToLower on List throws exception

I have the below code: public Expression FilterString(string property, string value, ParameterExpression parameter) { //Create Message MemberExpression from parameter and properted eg/Message.Body var getname = Expression.Property(parameter,…
Jon
  • 38,814
  • 81
  • 233
  • 382
3
votes
1 answer

How can I modify this Select2 javascript to enable paging?

I am not too familiar with javascript, so I need help here. I have this method which returns a list of Customers (2000+), so the Select2 dropdown hangs. I want to enable paging, but I am not sure what I need to change. Here is my javascript…
Xaisoft
  • 45,655
  • 87
  • 279
  • 432
3
votes
1 answer

Linq to Entities and SQL Server 2008 FileStream

Backend: SQL Server 2008 database with FileStream enabled Data Access: Linq to Entities I have thousands of pdf's that currently reside on a file server. I would like to move these pdf's off of the file server and into a SQL Server 2008 database so…
Jagd
  • 7,169
  • 22
  • 74
  • 107
3
votes
2 answers

Return Entity Framework objects from WCF

I am working on a WCF service to provide data to multiple mobile clients. Data model is Entity Framework 4.0. Schema is given below. When i returnt he object of SysUser the result also contains the navigation properties and EntityKey and other EF…
LojiSmith
  • 282
  • 3
  • 20
3
votes
2 answers

Using DateTime.Add(TimeSpan) with LINQ

I have to run a query like the one bellow. It is actually more complex, but here is the part that matters: var results = from b in _context.Bookings where b.ScheduleDate.Add(b.StartTime) >= DateTime.UtcNow select b; But it gives the…
Phillippe Santana
  • 2,906
  • 2
  • 28
  • 29
3
votes
6 answers

LINQ (to Entities) - Filtering items using ints

Using LINQ to Entities, how can I determine if any item from a List of ints exists in a comma delimited string of ints? For example, I want to write something like the following (logically):…
Jeremy
  • 9,023
  • 20
  • 57
  • 69
3
votes
2 answers

Entity Framework - Include in sub query?

I'm not sure if this has been answered yet, I looked at a couple of questions but I don't think they were quite what I was after. Let's say I have 3 tables: Restaurant 1.....M MenuCategory 1.....M MenuItem I have a L2E query that looks something…
Paul
  • 9,409
  • 13
  • 64
  • 113
3
votes
2 answers

"where" clause: entity id is in a potentially null array

I have an array of office ids, and the array is potentially null. I want the EF query to return all records if the officeIdsToSelect array is null, or only the matching records if it is not null. However this: int[] officeIdsToSelect = new int[] {…
Matt
  • 97
  • 1
  • 6
3
votes
1 answer

Linq to Entity - Inserting a record

I am new to Linq to Entity (Infact I am new to Linq) and I am struggling to insert a row. Following a number of tutorials (None of which seem to agree with each other or are very detailed) I managed to come up with the following code but I'm…
Lex Eichner
  • 1,056
  • 3
  • 10
  • 35