Relative Content

Tag Archive for c#entity-framework

Entity Framework Include return empty after manipulate child collection by Where function

I need to filter the elements and their child elements to display on the list, the idea was to search on the parent or child elements that contains the text to search, so I first launch the query with Include().
Then manipulate the result with the Where function on the parent and child elements.
But the EntityFramework had some strange results, the 1st time all went well, but when I wanted to do another EntityFramework search returned the parent elements with 0 child elements

EntityFramework 7, populate a property from another table

I have a TasksDbContext for my Tasks table where each task has a user identified by a UserId field, but the Users table is in a different database and is managed by a different team’s UsersDbContext. Is there a way to populate the task’s UserName property in my DbContext without stepping on the other team’s toes with regards to datamigrations etc.?

Does EF throw the exception if will be inserted row with non unique values when it’s required for table?

I would like to create algorithm for using only unique rows in some table, for avoiding repeating some rows. To do it, I’m enumerating existing table and looking for existing row, then create new or using reference for existing. But in case when database can be used with more then one user in the same time, both clients may have a different enumerated table (if one of them inserting some values already).