dbset Questions

1

Solved

Database Table Export to CSV using EntityFramework DbContext .NET 6 I have been tasked to create a Blazor ASP.NET Core application that will export each table from an MS SQL Server database into it...
Stroller asked 31/7, 2023 at 15:58

7

Solved

So EntityFramework 6 is a lot better testable then previous versions. And there are some nice examples on the internet for frameworks like Moq, but the case is, I prefer using NSubstitute. I've got...
Pearlene asked 12/1, 2014 at 0:57

5

Solved

In my application it is sometimes necessary to save 10,000 or more rows to the database in one operation. I've found that simply iterating and adding each item one at a time can take upwards of hal...
Harlandharle asked 17/7, 2013 at 21:40

2

Solved

string tableName = "TblStudents"; Dictionary<string, Type> myDictionary = new Dictionary<string, Type>() { { "TblStudents", typeof(TblStudent) }, { "TblTeachers", typeof(TblTeacher) }...
Aretta asked 4/10, 2018 at 1:56

4

Solved

For a few days now, I have been struggling with retrieving my entities from a repository (DbContext). I am trying to save all the entities in an atomic action. Thus, different entities together r...
Deland asked 26/2, 2013 at 16:59

6

Solved

I have following classes and DbContext: public class Order : BaseEntity { public Number {get; set;} } public class Product : BaseEntity; { public Name {get; set;} } public class Context : DbCon...
Inrush asked 3/2, 2014 at 17:19

4

Solved

Version Info: I am using C# 4.5, Entity Framework 6.0, and MEF. Code and Unit Test I created a Test Project to explain the problem: https://skydrive.live.com/redir?resid=E3C97EC293A34048!2234 P...
Nadbus asked 26/10, 2013 at 17:56

2

Solved

I'm trying to set up a mock DbSet for testing purposes. I used the tutorial here, http://www.loganfranken.com/blog/517/mocking-dbset-queries-in-ef6/ and slightly modified it so calling GetEnumerato...
Ormand asked 10/7, 2015 at 20:2

3

Solved

In LINQ to SQL, I can create a repository dynamically using DataContext.GetTable<T>. Is there a similar way to do this in Entity Framework 4 other than declaring the properties on the specifi...
Retinue asked 15/3, 2011 at 6:43

3

Solved

I want to select all rows from a table using the following type of syntax: public IQueryable<Company> GetCompanies() { return DbContext.Set<Company>() .// Select all } Forgive me a...
Cobaltite asked 1/12, 2012 at 11:15

4

Solved

Is there a way to inherits from DbSet? I want to add some new properties, like this: public class PersonSet : DbSet<Person> { public int MyProperty { get; set; } } But I don't know how to...
Faqir asked 6/12, 2013 at 15:42

2

Solved

I need to mock EF's DbContext. I use the approach here and it works well. // mock a DbSet var mockDbSet = Substitute.For<DbSet<Foo>, IQueryable<Foo>>(); var data = new List<Fo...
Chromatophore asked 14/9, 2016 at 10:34

2

Solved

I am working on a C# ASP.NET MVC 5 web application with EF 5. Mapping of my database tables using EF generates a DbContext class and an .edmx file. Today, I was reading a great article about creati...
Melano asked 15/4, 2016 at 16:58

1

Based on [the difference between Type.IsGenericType and Type.IsGenericTypeDefinition][1], I gained the piece of information I was missing in order to be able to retrieve a DbContext's DbSets via Re...
Burr asked 2/8, 2015 at 11:51

1

Following MSDN documentation we can use Local property to get local/cached data directly from the context without additional requests to a data source: Gets an ObservableCollection that represen...
Lithoid asked 18/4, 2015 at 11:46

2

Solved

Our programming involves some Mock testing using In-Memory Data. Therefore, we implemented the following code that would first create In-Memory Data of Customer objects // Let us create some in-m...
Crossbones asked 19/11, 2014 at 4:59

1

Solved

I'd like to use NSubstitute to unit test Entity Framework 6.x by mocking DbSet. Fortunately, Scott Xu provides a good unit testing library, EntityFramework.Testing.Moq using Moq. So, I modified his...
Perak asked 5/12, 2014 at 3:21

2

Solved

I am trying to implement pagination and sorting with generic repository. How to take primary key column as default order by column in DbSet ? DbSet = Context.Set<T>(); public IQueryable<...
Spellbound asked 24/10, 2014 at 15:14

1

Is there a way to use the method described in this answer No FindAsync() method on IDbSet for DbSet properties of a DbContext? Edit: The answer linked contains a description how to build a inter...
Chipper asked 19/5, 2014 at 6:25

0

How to create a custom DbSet to be used in our context, here I ferived from DbSet which the code sample is provided below. In the Context I have: public CustomDbSet<Items> MyDbSet { get; s...
Noni asked 24/6, 2014 at 11:37

1

Solved

I'm not sure that this is possible, but I'm trying to unit test a repository that uses a DbSet. I thought the easiest solution would just be to make an Enumerable, and replace the DbSet with that, ...
Baumgartner asked 9/9, 2013 at 4:25

1

Solved

Consider the following class: class MyContext : DbContext { public DbSet<Order> Orders { get; set; } } and instantiating a new object: var mycontext = new MyContext(); Why mycontext.Or...
Pneumoencephalogram asked 13/8, 2013 at 13:20

1

Solved

I have the following and looking for a more efficient way of deleting vs looping through the records and then deleting each one at a time (note using Dbset): var wcd = dbContext.ProgramDetails.Wh...
Clasp asked 11/10, 2012 at 2:0

1

Solved

I have the following 2 methods in my Logs repository. public IEnumerable<Log> GetAll() { var db = new CasLogEntities(); return db.Logs; } public DbSet<Log> GetAllSet() { var db ...
Lengthwise asked 14/8, 2012 at 1:45

1

Solved

I have the following code (Database is SQL Server Compact 4.0): Dim competitor=context.Competitors.Find(id) When I profile this the Find method takes 300+ms to retrieve the competitor from a tab...
Theatrical asked 27/7, 2012 at 10:42

© 2022 - 2024 — McMap. All rights reserved.