Questions tagged [dbset]

224 questions
1
vote
1 answer

Mocking DbSet with RhinoMocks and EF6

I am getting this error when I run my test: System.NotImplementedException : The member 'IQueryable.Provider' has not been implemented on type 'DbSet' ...' I saw this blog post on creating a fakeDbSet but that was before EF6. Is there a better way…
Robert
  • 4,306
  • 11
  • 45
  • 95
1
vote
1 answer

How to find an item in a dbset using linq

I am using C# and would like some help to write a LINQ FindAsync statement to find a MapLocation with a specific id. I have a DbSet, where each MapCompany has a List. I have the id of the MapLocation, and need to write a…
Simon
  • 7,991
  • 21
  • 83
  • 163
1
vote
1 answer

Dbset naming rules and class naming rules

I had a Dbset declared like so: public DbSet James_Bobs { get; set; } my Sql table is called James_Bobs the class holding the data was called James_BobRelation This does not work... when making calls to this within a…
Jimmyt1988
  • 20,466
  • 41
  • 133
  • 233
1
vote
0 answers

Cannot implicitly convert dbSet to ObjectQuery

That is my code and it doesn't work like this, please help me !!! public class BL: IBL, IDisposable { private TradeSoftDBEntities entities; public List TakeRoles() { if (entities == null) entities = new…
1
vote
1 answer

Is DBSet required for direct access?

I'm pretty sure I know the answer already, but I need it confirmed by others. The question concerns the use of DbSet in Entity Framework: Code First. (Using C#) Let's use these small classes as an example: class TopClass { Public…
Darth_Sygnious
  • 528
  • 3
  • 7
  • 18
1
vote
0 answers

how can I Reload ALL Entities (Entries) in my DbSet (not ONE entry)?

how can I Reload ALL Entities (Entries) in my DbSet (not ONE entry)? i have 2tables: Tbl1 (Id, Name, Tel,...) Tbl2 (Id, Address, DetailInfo,... ) and 1 view: MyView1 (Tb1.Id , Name,Tel , Address , DetailInfo,...) I set DbSet.ToList() in the grid's…
kiared
  • 39
  • 4
0
votes
0 answers

Is there any way that I can move my DbSets (from DbContext) like how we done it with configurations in fluent API?

I want my DbContext to have no additional code in it (and I had another problem with my DbContext, the problem is when my DbSets gets too many) So another question, Is it a bad thing that I want to separate DbSets from DbContext? public class…
0
votes
0 answers

DbContext's DbSet<> member throws InvalidCastException upon DbSet.ToArray(), trying to cast to another declared entity type

I'm using EntityFrameworkCore 7.0 in conjunction with Pomelo.EntityFrameworkCore.MySql to build a Code-First app relying on MySQL. I'm using the Fluent Api and IEntityTypeConfiguration<> implementations for each and every entity class there is in my…
0
votes
1 answer

Not able to convert System.Data.Entity.DbSet`1 to type 'System.Data.Entity.DbSet`1

I have created an interface and a class which implements that interface and I am trying to assign the interface reference the class object after querying it form the database public interface IErrorCodeMapping : IEntity { int Id { get; set; }…
ravikiran
  • 33
  • 6
0
votes
0 answers

DbSet only .Remove or .RemoveRange not working

I am trying to write a unit test for removing items from my dbset using the code below var entitySet = Context.Set(); var entitiesToRemove = await entitySet.Where(request.KeyExpression) …
HSwinnie
  • 1
  • 3
0
votes
1 answer

One Entity for multiple DBSets

I'm looking for a solution or good practice to use a class for example -> "Account" in several DBSets, so that public class Account { public string ID {get; set;} public string Name {get; set;} } for multiple DBSets would be something like…
earlO
  • 35
  • 3
0
votes
0 answers

Group by internal class property value

public class Cat { public int Id { get; set; } public string Name { get; set; } public Breed Breed { get; set; } } public class Breed { public int Id { get; set; } public string Name { get; set; } } How to GroupBy a DbSet…
Nick Farsi
  • 366
  • 4
  • 19
0
votes
0 answers

EF Core 6.0 get InternalDbSet<> from type

I do have a problem with EF Core. I need a Instance of a DBSet<> without knowing the Type until runtime and method is called. I need this Instance to add Include Statements dynamically and finally load the information from DB. I do get an object,…
0
votes
1 answer

Configuration for Database Connection

Please I'm new to C# and I've been trying to configure my code to work with a database. I need a proper and step by step guide on how to go about it. Thanks I have created a class that inherits from Dbcontext and also configured it in program.cs but…
0
votes
0 answers

How to create generic DbSet table that can be used in linq query

I have 3 Entity DBSet table => (Table1, Table2, Table3) Three of them have same properties name => (id, UserName, Role) Question: how do I create a function that can be used for 3 different DbSet table? Can we create a generic DBSet and access…