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

Strongly Typed include not available

I have upgrade from EF 4.0 to EF 4.2 My context inherits from ObjectContext. The strongly typed Include method (to include linked entities in the results) is not available on my entities sets (that inherit from ObjectSet). Why?
2
votes
3 answers

LINQ inheritance "Down-Cast" with a new Property

I have the following two classes: public class Base { public int Id { get; set; } public string PropertyA { get; set; } } [NotMapped] public class Derived : Base { public string PropertyB { get; set; } } And I have the following…
Shion
  • 1,499
  • 2
  • 14
  • 29
2
votes
1 answer

LightSwitch custom query with LINQ using delegates does not work

I have problems in designing an extended query in the ...PreprocessQuery() Method of a LightSwitch query. 1st of all, I tell you in a simplified way, what works: partial void NeedHelp_PreprocessQuery(bool Admin, ref IQueryable query) { //…
Satria
  • 315
  • 2
  • 9
2
votes
2 answers

Making thing more succint using linq to entities for inner joins

Any way to make this less verbose? var model = ( from MvrTable in LinqEntitiesCtx.Mvrs join MvrMedsTable in LinqEntitiesCtx.MvrMeds .Where(Id => Id.FKMvrId == 1)//inner join will be fast with this! on MvrTable.PKMvrId equals…
hidden
  • 3,216
  • 8
  • 47
  • 69
2
votes
1 answer

Compare date part in where clause

When tried to condition the where statement to only compare the date part of the datetime field using this code, var list = products.Where(x => ((DateTime)x.PurchaseDate).Date >= dt_SelectDate.Value.Date); I used the (DateTime) conversion because…
2
votes
2 answers

Linq to Entities - 'where' to bring back a list of Products and associated items checking both are enabled

Can anyone help me with the following? I'm using Linq to entities (code first). I have a Products object which is mapped (1 to many) in my db context to my ProductAreas Object. This query works and brings me back a list of enabled products…
carok
  • 648
  • 6
  • 14
2
votes
2 answers

Is Linq to SQL faster than Linq to Entities?

I was having a discussion with a colleague of mine. We use Linq to Sql at work and I am kind of new at the job so I asked him why we are not using Linq to Entities? He made a few arguments and one of them was "Because Linq to Entities is slower than…
NomenNescio
  • 2,899
  • 8
  • 44
  • 82
2
votes
1 answer

Return joined table

i had type this linq query for my domain context but why it would failed to retrieve the data of both table matched student id in tblaptmt ? public IQueryable StudentViewAppointments(string StuId) { …
1myb
  • 3,536
  • 12
  • 53
  • 73
2
votes
2 answers

Populate list in POCO using subselect - LINQ to entites

I am trying to create a list of POCOs from my database. The POCO class has a List property which I want to populate like so: public List GetData() { using (EFContext c = new EFContext()) { var query = from t in…
Sprintstar
  • 7,938
  • 5
  • 38
  • 51
2
votes
4 answers

converting int to string in linq to entites

My Code is : var currency = (from ac in db.shop join cur in db.books on ac.CODE equals cur.CODE.ToString() //here is the Error // because "ac.code is type strig" & "cur.code is type long where ac.ID…
Onlineuser
  • 56
  • 1
  • 6
2
votes
1 answer

Filtering Linq to Entity on Lazy Loading 3 levels Nested Query

Assuming a Entity Framework, in a LazyLoading context. We have 3 entities: Product(which has many Order Details) OrderDetails(which has many Details) Detail The following query brings all Products with Name=Books. And to each of these products…
2
votes
1 answer

Can I make this Linq to EF more efficient?

I have a design where we store answers to scripts's questions by given users. One script can have many questions and each question can be answered multiple times by a given user. The MS SQL tables look (removing extra details) more or less…
qbantek
  • 685
  • 12
  • 32
2
votes
2 answers

SQL to LINQ Converter

I have a SQL and having a hard time to convert it to LINQ. Are there any other tools that can convert SQL to LINQ? I heard Linqer and tried it but it doesn't allow you to query on the Junction/Join Table of a Many-to-Many relationship tables. In any…
gnaungayan
  • 522
  • 1
  • 9
  • 22
2
votes
1 answer

EF 4.1 Linq to Entities Contains works with List but not T[]

I'm using Entity Framework 4.1 on a SQLCE 4 database and my context is a DbContext. The purpose of the following code is to search for a list of entries where the "ProtocolName" property is contained within a given list. This version of the code…
2
votes
3 answers

LINQ "Where" Statement Doesn't Work

I'm a bit confused why this piece of code produces 2 records in a list (acts appropriately): var historiesToRemove = new List(); foreach (var history in this.WorkHistories) { if…
Martynas
  • 1,064
  • 10
  • 21
1 2 3
99
100