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

Entity framework - select nullable join property

My table structure looks like : Account AccountId LoginName EmployeeId - nullable Employee FirstName, SecondName, etc.. I have query : var data = from o in _accountRepository.AsQueryableWithIncludes(x => x.Employee, x => x.Permissions) …
Mennion
  • 2,873
  • 3
  • 20
  • 34
2
votes
2 answers

How can I pass an expression to act on a single field in an anonymous type in LINQ

I have the following Data Transfer Objects defined: Public Class MemberWithAddressesDTO Public Property Member_PK As Integer Public Property Firstname As String Public Property DefaultAddress As AddressDTO Public Property Addresses As…
2
votes
2 answers

Linq Checking if a subquery is empty without hitting remote database

I have a linq subquery as follows: for (int i = 0; i < parentAttributes.Length; i++) { Guid parent = parentAttributes[i]; var subQuery = from sc in db.tSearchCluendexes join a in…
kh25
  • 1,238
  • 1
  • 15
  • 33
2
votes
1 answer

Can new type classes be created in Linq-to-Objects?

To create and assign classes on the fly from other objects I usually use LINQ. Suppose I have a IQueryable object fetched from my Database and, for some reason, I need to create an IQuaryable where each Product properties…
CiccioMiami
  • 8,028
  • 32
  • 90
  • 151
2
votes
2 answers

Combining two LINQ queries into one

I have a table that has a about 15 different fields, some of which are JobID (integer field), Cost (integer field) and LastUpdated (DateTime field) JobID Cost LastUpdated 1 10 10-July-2011 1 15 11-June-2011 2 …
user20358
  • 14,182
  • 36
  • 114
  • 186
2
votes
2 answers

Linq vs Lambda-Expressions query execution and "1 AS [C1]" meening in executed query

I have the same query written in both LINQ and the Lambda-expressions way: LINQ: var str = (from userInfo in context.UserInfos join user in context.Users on userInfo.UserId equals user.UserID join membership in context.Memberships on…
Chuck Norris
  • 15,207
  • 15
  • 92
  • 123
2
votes
2 answers

Linq to Entity Framework return a list of parents with only a subset or empty collection of children

Given a list of parents and their children I want to return a list of all parents and only their male children. This is trivial in a sql query. The problem I have is with Linq to EF I cannot seem to get the query to work in any fashion. Due to EF…
cjibo
  • 4,487
  • 6
  • 27
  • 34
2
votes
2 answers

LINQ Max Grandchild

I have the following hierarchy of objects in Entity Framework Code First: class Parent { public int Id { get; set; } public string Name { get; set; } public virtual ICollection Children { get; set; } } class Child { public…
Dismissile
  • 32,564
  • 38
  • 174
  • 263
2
votes
2 answers

Simplify this property to be used in a predicate

I have many Accounts, each account can also have child accounts. So my way of knowing if an account is root is thanks to the value in the ParentId property. So it turned out that my code has stuff like this in many places: .Where(acc => acc.ParentId…
2
votes
3 answers

System.Linq.Select method error: LINQ to Entities does not recognize the method

Good day, My code generates a run-time error and I'm not sure how to fix this. Any help would be appreciated. Our code is calling the second Convert method below by passing a list of "offers". The offer is an object from an EDMX model. The first…
Matei
  • 327
  • 5
  • 17
2
votes
1 answer

INNER JOIN in EF 4

i have 2 tables master and details, in EF 4 i want to write a query to retrieve a data like this t-sql SELECT Table1.Table1ID, Table1.A, Table2.Table2ID, Table2.B FROM Table1 INNER JOIN Table2 ON Table1.Table1ID =…
motevalizadeh
  • 5,244
  • 14
  • 61
  • 108
2
votes
0 answers

Linq to Entities Gracefully Handling Database Variances

I notice that even slight variances between the database and the entity model will cause queries to fail. For example, say a column is added to a table that I am querying, even if that column is inconsequential to the query it will fail. Is there…
Perishable Dave
  • 2,858
  • 2
  • 24
  • 29
2
votes
2 answers

Adding a random Guid column to a Linq to Entities query to grab random records

I've found some articles about using the RandomView view and the GetNewID function to pull back randomized records, but they are using this method with Linq to SQL which allows Functions and Stored Procs to be used with no return value or a scalar…
Jeremy Sullivan
  • 995
  • 1
  • 14
  • 25
2
votes
2 answers

LINQ to Entities - Rounding to the nearest dollar, nearest half-dollar, or not at all

I need to round FinalPrice the following ways based on an identifier: 0 = Not at all 1 = Up to the next Dollar 2 = Up to the next Half-dollar Example of the expected rounding: ID 0: 133.15 => 133.15 ID 1: 133.15 => 134.00 ID 2: 133.15 => 133.50 …
Greg Snider
  • 143
  • 1
  • 9
2
votes
4 answers

Ado.Net entity framework, linq: select multiples tables

I use these sentence in C# to retrieve data from tables DetalleContenido and Archivo: var detallesContenido = from contenido in guiaContext.Contenido where contenido.PuntoInteres.id_punto == puntoInteresID from dc in…
VansFannel
  • 45,055
  • 107
  • 359
  • 626