Linked Questions

202 votes
7 answers
268k views

Ok, I have tri-leveled entities with the following hierarchy: Course -> Module -> Chapter Here was the original EF LINQ statement: Course course = db.Courses .Include(i => i....
AnimaSola's user avatar
  • 7,936
87 votes
5 answers
57k views

Is there a way to decorate your POCO classes to automatically eager-load child entities without having to use Include() every time you load them? Say I have a Class Car, with Complex-typed ...
Nathan Geffers's user avatar
51 votes
6 answers
71k views

I'm trying to get data from a LocalDb into my MVC Controller. I tried this: UsersContext db = new UsersContext(); var users = db.UserProfiles.Where(u => u.UserId == WebSecurity.CurrentUserId) ...
JazzMaster's user avatar
67 votes
2 answers
34k views

I want to get multiple nested levels of child tables in Entity Framework Core using eager loading. I don't think lazy loading is implemented yet. I found an answer for EF6. var company = context....
zoaz's user avatar
  • 2,109
46 votes
3 answers
74k views

I'm new to using LINQ to Entities (or Entity Framework whatever they're calling it) and I'm writing a lot of code like this: var item = (from InventoryItem item in db.Inventory where item....
JC Grubbs's user avatar
  • 40.5k
42 votes
1 answer
47k views

I'm transfering my .NET Framework (EF6) code to ASP.NET Core (EF Core), and I stumbled upon this issue. Here is some example code: In EF6 I use Include() and Select() for eager-loading: return ...
nikovn's user avatar
  • 2,018
2 votes
1 answer
5k views

Application Version: Asp Net Core 1.1 EF: Microsoft.EntityFrameworkCore (1.1.1) Line: _dbContext.MyTable1.Include(c => c.MyIntermediateTable).ThenInclude(k => k.Select(x => x.MyTable2)).ToList(); ...
Mario Guadagnin's user avatar
0 votes
2 answers
3k views

The above is my database .I have for tables Contact,Countries,States,Cities.The Country in contact table is foreign key to the Id in countries table. And I am using entity framework to get the data.I ...
Bharat Bhushan's user avatar
0 votes
1 answer
4k views

I have been searching the NET and SO for some answers - I am pretty much a noob to Entity framework .. so I do have some confusion on related entities .. I am using C# , Winforms, Linq , EF6^ (...
Ken's user avatar
  • 2,908
3 votes
2 answers
2k views

MY Model M:M relationship Reference to https://www.entityframeworktutorial.net/efcore/configure-many-to-many-relationship-in-ef-core.aspx Models public class Post { [Key] public int Id { get; ...
ZCoder's user avatar
  • 2,339
4 votes
1 answer
1k views

My data model has a lot of nested entities and I would like to eagerly load the whole object tree ... except for a view entities that will be explicitly loaded on demand. Using include paths I have ...
Stefan's user avatar
  • 12.8k
1 vote
2 answers
1k views

Here's my problem: I have a class that have 2 list properties of the same class type (but with some different restriction as on how to be filled), let's say: public class Team { [Key] ...
Marcelo Myara's user avatar
2 votes
0 answers
2k views

I'm using Entity Framework to save my data to a database. Now I have a class: public class User { public int Id { get; set; } public virtual ICollection<User> Friends { get; set; } ...
Florian's user avatar
  • 1,897
1 vote
2 answers
732 views

I'm trying to figure out how can i retrieve roles with Any and check if user exists on the same query and return as SingleOrDefault() but doesn't seem to work. private User Authenticate(...
Jackal's user avatar
  • 3,531
0 votes
1 answer
1k views

I'm trying to use ASP.NET Core 2.2.0 with Entity Framework Core and I'm facing a bit of troubles. I want to display a list of pictures of different celestial objects I took (nebula, galaxies, etc...). ...
F.Carette's user avatar
  • 103
1 vote
2 answers
1k views

Since upgrading from .NET Framework to .NET Core, I've encountered an unexpected behavior in Entity Framework Core related to the use of .Include() and .AsNoTracking() methods. Consider the following ...
user3261212's user avatar
0 votes
1 answer
656 views

I have a list on SharePoint, where I am trying to load fields for this list like following: var lists = context.Web.Lists; context.Load(lists, n => n.Include(x => x.Title, ...
Robert J.'s user avatar
  • 2,721
0 votes
1 answer
815 views

Im making a movieshop for school. I have a movie as a domain model, and each of these models has another model, Genre, as a property. Now when i save this to the database, it adds the movie and the ...
Jonas Olesen's user avatar
1 vote
1 answer
435 views

I am trying to shape HTTP GET request where entity wall and some of its parent table(User) rows are displayed. I succeded getting the whole parent row, but I am struggling with select statement where ...
fcuic's user avatar
  • 36
1 vote
2 answers
288 views

How do you mix the concepts of ASP.NET MVC and entityframework in a elegant and robust way when it comes to retrieving stuff from the database and visualizing it via the controller and view? The ...
bas's user avatar
  • 15.2k
0 votes
0 answers
371 views

I want to display list of users with products of every user. So I have this in my classes : public partial class User { public User() { Product = new HashSet<Product>(); } ...
mecabmecab95's user avatar
1 vote
1 answer
262 views

I have nested entites like example from msdn. var blogs1 = context.Blogs .Include(b => b.Posts.Select(p => p.Comments)) .ToList(); But in my case, ...
flybox's user avatar
  • 224
2 votes
2 answers
93 views

I have an entity called Address. An Address contains a complex type, called House. A House contains a reference to its occupants. An Occupant is an entity. public class Address { [key] ...
CodeTower's user avatar
  • 6,333
0 votes
2 answers
222 views

I am using the code-First approach of MVC facing the below issue. I have 1 The Admin model which has 2 properties that represent a separate class as shown below respectively. public class Admin ...
Satish's user avatar
  • 57
0 votes
1 answer
163 views

Here is Repository, in which I created a methods in which I needed the data on the basis of intermediate table. public Task<IEnumerable<DepartmentSchool>> GetAllDepartmentBySchoolIdAsync(...
Vipin Jha's user avatar
  • 117
0 votes
3 answers
121 views

I have a project with two tables, Loans and LoanTypes, and as shown below I've set them up with model classes. The problem is in my controller: when I list loans, there is no LoansType for this loan. ...
Bilal Saad's user avatar
0 votes
0 answers
128 views

I have SQL Query ready, and that I want its result into a complex SQL object. I want to use Linq to achieve the result. public class VMPackageList { public string PackageName { get; set; } ...
Anrorathod's user avatar
1 vote
0 answers
97 views

I have the following controller method: public IActionResult Get() { IEnumerable<Hour> _hours = _hourRepository .AllIncluding(h => h.Customer.name, h => h.Payer.name) ...
phicon's user avatar
  • 3,627
0 votes
1 answer
44 views

Trying to get child of child, both with many relationship. So a CarePeriod has many DailyExerciseSets which has many ExerciseTrials. so carePeriod has collection of DailyExerciseSets which has a ...
michaelBurns's user avatar
1 vote
0 answers
36 views

As you can see here I have two entities that are linked with each other in two ways. First way is classic many to many by two ICollection and second is by entity GroupRole which specifies role of user ...
cyman1998's user avatar
  • 113

15 30 50 per page