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

How to choose from two connection strings?

Good afternoon, I have encountered a problem to choose from two connection strings using C# and Linq to Entities. Currently I have two connection strings which are:
2
votes
3 answers

GridView doesn't show results with First() query extension

I am using LINQ-to-Entities and have loaded up a Northwind Database (with LazyLoading=true). var db = new NorthwindEntities(); var result = db.Orders.Where(x => x.CustomerID == "ANATR").First(); DataGridView1.DataSource = result; The above…
ColdFusion
  • 93
  • 8
2
votes
1 answer

Entity Framework Query with MAX

I've been banging my head against the wall trying to translate a simple SQL Query into EF query.. Can anyone help please.. Following is the query I am trying to translate. SELECT p.[UniqueId] ,p.[CAI] ,p.[HRGuid] ,p.[FullName] ,p.[Email] …
2
votes
1 answer

how to get utc fotmat date and time WCF from sql server by using Linq or something

i am using DateTime.UtcNow to store the date in my database .. while retrieving i need to filter on only today's date means for the latest .. i need some suggestions
susant
  • 382
  • 3
  • 11
2
votes
1 answer

ASP.Net Linq to Entities: An attempt to attach an auto-named database failed

The problem is that the path to my database shown in the error below is incorrect. I cannot find where that path is set as it is not in the settings or in any of the project files. What am I missing: The error: An attempt to attach an auto-named…
Susan
  • 1,822
  • 8
  • 47
  • 69
2
votes
2 answers

Converting LINQ to Entity stement with not contains into a Lambda expression

I have three entities as shown below. Student { StudentID, Name, Age } Parent { ParentID, Name, Age } StudentParent { StudentParentID, StudentID, ParentID } I need to get an IQueryable list of students that are a certain age and have no…
Chad Myers
  • 106
  • 1
  • 7
2
votes
1 answer

Linq to Entities many-to-many join

My first time using the Entity Framework so I'm not sure if I'm doing this right. I have 4 tables: CustomerOrder ------------ ID, StaffID, DeptID, Status, other columns... Staff ------------ StaffID, other…
JumpingJezza
  • 5,498
  • 11
  • 67
  • 106
2
votes
1 answer

EF4: Filtering out referenced entities that do not exist

I have an Entity Framework 4 design that allows referenced tables to be deleted (no cascade delete) without modifying the entities pointing to them. So for example entity A has a foreign key reference to entity B in the ID field. B can be deleted…
Eric Sassaman
  • 1,401
  • 1
  • 18
  • 23
2
votes
1 answer

Displaying associated table using LINQ

I am working with the Entity Framework model. With the help of LINQ, I am trying to load entities and their associated data in a single query (i.e. to implement eager loading). Here's the code-behind: protected void btn5_Click(object sender,…
Michael
  • 13,950
  • 57
  • 145
  • 288
2
votes
2 answers

Three-Tier architecture and LINQ to Entities

For a couple of years, I've been using the three-tier architecture (Presentation, Logic and Data Layer) to write applications. Usually, I am using tools such as .netTiers to generate the data layer and partially the logic layer. Everything is well…
Martin
  • 39,309
  • 62
  • 192
  • 278
2
votes
3 answers

How to build a query like the selectbyexample using linq-to-entities?

How to build a query like the selectbyexample using linq-to-entities? For example: public class Person { public string Name {get; set;} public int Age {get; set;} public string City {get; set;} } If I had a new Person() with all…
Vinicius Saeta
  • 183
  • 1
  • 2
  • 13
2
votes
1 answer

LINQ - select query in related objects Entity Framework (EF4)

For the following (I'm using EF4) I need to select all messages in a Thread (ContactThreadId) that were NOT yet read given LoginId So, i based on ContactThreadId and LoginId I need to know if this LoginId has already read all messages in a Thread.…
ShaneKm
  • 20,823
  • 43
  • 167
  • 296
2
votes
1 answer

How can I use IQueryable.Include with Inheritance

I think I use TPT inheritance. I have an abstract parent class and three subclasses. What I want is a basic find function, but I need to explicitly do includes. My problem is how can I include different properties based on the type. public…
Alec
  • 1,646
  • 3
  • 19
  • 35
2
votes
2 answers

Why does my Linq Where clause produce more results instead of less?

I just had the weirdest debug experience in a very long time. It's a bit embarassing to admit, but it lead me to be believe that my Linq query produces MORE results when adding an additional Where clause. I know it's not possible, so I've…
Adrian Grigore
  • 33,034
  • 36
  • 130
  • 210
2
votes
1 answer

LINQ to EF, Left Join and group by clause

I have this SQL: select o.prod_id, SUM(o.[count]) as [count] into #otgr from otgr o where o.[date]<= @date group by o.prod_id select f.prod_id, SUM(f.[count]) as [count] into #factory from factory f where…