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

Return entity with latest timestamp matching a userId LINQ

I am stuck on this. I have two tables: Users2Users and ActivityLog. I want to look up the list of Users2Users that are a user's friends and return each of their latest activity based on its Timestamp, then check what type it is. Users2Users int…
testpattern
  • 2,382
  • 1
  • 25
  • 29
3
votes
1 answer

Linq to Entities Query is failing to execute

I'm trying to create a query object that contains information from 3 different entities. When the query executes, it tells me an EntityServerException was unhandled. I'm using a DTO for specific columns to be pulled. Here's my basic DTO: public…
justin peterson
  • 367
  • 1
  • 6
  • 17
3
votes
1 answer

Using IQueryable Where with Expressions with more than one parameter

I am using LINQ to Entities and querying for entries within a certain date time period, held in model object which has the properties DateFrom and DateTo. To do this I can use the following to create a sequence var allActiveLogs =…
AlexC
  • 10,676
  • 4
  • 37
  • 55
3
votes
0 answers

Issue with Linq-to-Entities, parameters and DB2 9.5.3

First, some background info about the environment... There are two machines: Windows “client” and Linux “server”. Windows 2008 R2 x64 • IIS 7.5 • NET 3.5 • SharePoint 2010 • Visual Studio 2010 • IBM DB2 .NET Data Provider Runtime Version…
Ami Schreiber
  • 287
  • 2
  • 6
  • 20
3
votes
3 answers

C# LINQ to Entities- Properties on the intersection of an object and a collection of objects

I used to ask a similar question which was aiming to understand how to get the models at the other set which are having the same property with the one I am holding. Now the problem is: So, what was the name of the "similar property" which actually…
Görkem Öğüt
  • 1,761
  • 3
  • 18
  • 29
3
votes
1 answer

Find a word in a string where the string can be null (sometimes)

I have to find a word in a LINQ to EF search. so I wrote the following code var Q = (from k in MyList where k.Name.Contains(query) || k.Description.Contains(query) select k).Count(); if (Q == 0) …
Reza.Hoque
  • 2,690
  • 10
  • 49
  • 78
3
votes
3 answers

Why does .Where() on an IQueryable return a different type based on whether a Lamba or Func are passed as parameters

In my Entity Framework Code First project I have a repository object which contains routes public class EFRepository { ... public IQueryable Routes { get { return context.Routes; } } ... } If I run var routes =…
AlexC
  • 10,676
  • 4
  • 37
  • 55
3
votes
1 answer

Entity-Framework -> MySql gives 'Function evaluation timed out.'

I having a weird problem with Entity Framework with MySql database. Here's the code that I've got. public class testbase { private testEntities db = new testEntities(); public IQueryable GetRecords() { return db.record; …
Cyril Gupta
  • 13,505
  • 11
  • 64
  • 87
3
votes
1 answer

MVC 4 late-bound DataContext entity LINQ reference

Long time listener, first time caller. I'm probably taking the wrong approach to this, so any help would be fantastic. I'm using C#, MVC 4, Code First, Entity Framework 4.3, & Razor. I am trying to split out EF data classes & some methods into a…
3
votes
1 answer

Dynamic Linq .Select() - How to handle certain null values

I am using System.Linq.Dynamic for a project that requires the user to choose which properties will be selected/projected at runtime. So, I have a query like this: var query = db.Users.Select("New(UserId, Username, Groups.Max(DateInserted) AS…
Fred Wilson
  • 2,177
  • 3
  • 17
  • 21
3
votes
2 answers

Cannot convert lambda expression when comparing 2 integers

Cannot convert lambda expression to type 'bool' because it is not a delegate type When comparing 2 integers in the if statement "if (UserLevelID => dbMinimunlevelID)" How can I compare a variable that holds a count with another integer? //Check…
MataHari
  • 318
  • 3
  • 6
  • 15
3
votes
2 answers

Linq Expression to execute existing expression on a child property

Here is a simple class public class Parent { public Child Child { get; set; } } Here is the method I'm trying to implement Expression> GetChildIDExpr(Expression> objectIdExpr) { //So I need to return an…
Connell
  • 13,925
  • 11
  • 59
  • 92
3
votes
1 answer

Select EF entities that have all the given Tags (where tag is an EF entity)

I have the following situation: An "Conversations" entity/table which has multiple Tags associated to it. Tag is also an entity/table - the key/id is tagName (a string). On the client side (javascript) I work with arrays of string when dealing with…
Ando
  • 11,199
  • 2
  • 30
  • 46
3
votes
1 answer

Integrating custom method into LINQ to Entities query

I have a custom method that performs some calculation on a set of data: private int GetPercentages(int OriginalValue, int TotalValue) { var newValue = (int)Math.Round(((decimal)OriginalValue / (decimal)TotalValue) * 100); …
user547794
  • 14,263
  • 36
  • 103
  • 152
3
votes
1 answer

Query which returns results only if all (non-primitive) values from a compared enumerable are contained in the target enumerable

We have a collection of entities of type called Unit, collection of entities of type UnitProp and a collection of entities of type called Prop defined like this (simplified): class Unit { int ID; ICollection UnitProps; } class…