Questions tagged [dbset]
224 questions
0
votes
2 answers
Querying Entity DbSet with variable Object Type
I have a method with a ValidationContext as parameter.
Here is an exemple of what I would like to achieve.
The objective is to check if there are duplicates in the DbSet if it'a Vehicule, on DbSet if it's a Color, etc...
protected…

Manta
- 490
- 5
- 18
0
votes
1 answer
Storing DbSet in constructor instead of calling DbContext.Set for every use
In a repository pattern I've been following for a while (example), I've always had Add, Delete, etc. methods which use a "new" DbSet (e.g., DbContext.Set.Update(entity). In testing, this seems to, thankfully, always return the same DbSet object.…

Dinerdo
- 560
- 7
- 27
0
votes
1 answer
Dynamicly set the datasource in EF
I am using EF6 and I have 2 different versions of databases (MsSQL).
1 version has a table Person and the other one has not.
I am overriding theOnModelCreating and I use the modelBuilder.Ignore();
This works for calling the database for…

Tom Wauters
- 3
- 2
0
votes
1 answer
C# ODataQueryOptions with EF6 navigation property filters. System.ArgumentNullException : Value cannot be null. Parameter name: type
I've a parent class
public class Audit : BaseModel//Properties are intentionally made non virtual
{
public string Name { get; set; }
public int FacilityId { get; set; }
public string Passcode { get; set; }
public…

singh_g99
- 19
- 6
0
votes
2 answers
Get DbContext's DbSet where T is variable
I have a DbContext looking somewhat like this:
class MyDbContext: DbContext
{
public DbSet Set1 {get;set;}
public DbSet Set2 {get;set;}
...
}
where Class1, Class2 ... : BaseClass
The thing is I'm reading data from xml…

Никита Львов
- 898
- 7
- 10
0
votes
0 answers
Unable to update DbEnitity.! EnityValidation occurs! Customer parameter returns null when trying to edit or save it
I am using codefirst approach and entity framework to update my Customer by changing the name but EnityValidation Error occurs.As I try to debug it using trycatch block it shows the name field is required.
Error message while debugging
I used data…
user8164624
0
votes
2 answers
Unable to delete using dbSet - Entity Framework
I am using EF6 and I am trying to delete an entity like this:
public virtual void Delete(TEntity entity)
{
DbContext.Configuration.ValidateOnSaveEnabled = false;
DbContext.ChangeTracker.DetectChanges();
…

Naveed Khan
- 73
- 2
- 15
0
votes
0 answers
Entity Framework: Data size is to large. Any alternatives?
The Enity Framework has worked great for me and I'd Like to keep it. However, one of my DbSets has 17 million records and growing quickly. Querys to that dataset take way to much time. Is there a way I can change the structure of a way to speed the…
0
votes
1 answer
EntityFramework 6 out of memory exception
Hej,
I have a table in database that holds compressed large size file.
when I try to read that file via a Ef6. It throws an out of memory exception.
Any help would be appreciated.
My code is like
var payload = repositoryContext.Set()…

user3661407
- 525
- 3
- 9
- 18
0
votes
1 answer
Adding entities sets dynamically in dbcontext the repository layer doesnt compile
My DbContext code is similar to this:
public class MyDbContext : DbContext, IMyDbContext
{
public DbSet Customers { get; set; }
public DbSet Products { get; set; }
...
}
And I want to add dbsets in dbcontext dinamically,…

vicky_864
- 57
- 8
0
votes
1 answer
How to update database using DbSet
In my MVC application I have a method, that should add an entity to database (if it is doesn't exist), or update it (if it is already in database)
//...
var list = _context.CurrencyRepository.Get().ToList();
foreach (var…

Egor
- 153
- 1
- 2
- 10
0
votes
0 answers
EntityFrameworkCore DbSet.Where
I want to filter my DbSet by multiple Lambda expressions.
Here is the implementation.
1.Expression
public static Expression> True() { return f => true; }
public static Expression> And(this Expression

Edward
- 28,296
- 11
- 76
- 121
0
votes
1 answer
Return DbSet based on selection
I'm writing an ASP.NET Core MVC web app that is a tool for handling a parts database. What I want is for the user to select a Part and then that will do some action, like delete that part from it's DB. However, I want this to be a generic action…

Joe Higley
- 1,762
- 3
- 20
- 33
0
votes
0 answers
Force a query on a DBSet before before use
This may not be the right approach however, perhaps someone will have a better take on it
I am looking for a way to force a parameter query when calling a DBSet property in a DBContext.
public DbSet Users { get {…

chrisdyck
- 27
- 1
- 8
0
votes
1 answer
Modify object without affecting base database table in Entity Framework?
I have a postgres database containing numberous tables. The project is implemented using Entity Framework.
I have 3 database classes lets say A, B & C. Class A contains list of B's objects. Class B contains list of C's objects. Class C is a simple…

vinmm
- 277
- 1
- 3
- 14