zzz projects Entity Framework Core EF Core
Home Articles Knowledge Base Online Examples
  • Home
  • Articles
  • Knowledge Base
  • Online Examples

Entity Framework Core - Knowledge Base (KB)

17 results in tag: generics

Implementing Generic Service for CRUD operations using EF6

I've done multiple projects using the Repository pattern(Interface=>Repository)but now, I'm facing a new challenge(not a big one) with one of my coworker's code. We are implementing a Generic service that contains all of the CRUD operations methods for al...
c# entity-framework entity-framework-6 generics repository-pattern
asked by Alexander P.

There is no implicit reference conversion from ApplicationUser to IdentityUser

I am trying to customize some ASP.NET Identity Core classes which use Generics....My ApplicationUser class:...public class ApplicationUser : IdentityUser<Guid>//, ApplicationUserClaim, ApplicationRole, ApplicationUserLogin> { public ApplicationUser()...
asp.net-identity c# entity-framework-6 entity-framework-core generics
asked by Legends

Register generic EntityFrameworkCore DbContext in ASP.Net Core 1.0

I am trying to use generic DbContext in ...ASP.Net Core 1.0... however I am getting following error:...ArgumentException: Type 'idmin.data.IdminDataContext`1[System.Int32]' does not have a default constructor Parameter name: type ...Here is how IdminData...
asp.net-core-1.0 asp.net-mvc c# entity-framework-core generics
asked by Pankaj Kapare

Get Id of Generic Entity of EF 6

I write a generic repository to CRUD in EF.In add method is written like this...public class GenericRepo<T> where T : class { //Create public static void Add(CellPhoneProjectEntities dbContext, T entity) { dbContext.Set...
c# entity-framework entity-framework-6 generics
asked by syed mhamudul hasan akash

Is there a way to generically mock the DbSet.Find method with Moq?

I'm currently using an extension method to generically mock DbSets as a list:... public static DbSet<T> AsDbSet<T>(this List<T> sourceList) where T : class { var queryable = sourceList.AsQueryable(); var mockDbSet = new Mock<DbSet<T...
c# entity-framework entity-framework-6 generics moq
asked by C. Williamson

Design of abstract generic DbContext class in EF Core

I'm having trouble implementing an abstract generic base class, using EF Core. It's probably something obvious, but I'm not seeing it....base class:...public abstract class AContext<TUser> : IdentityDbContext<TUser> where TUser : IdentityUser { pu...
c# entity-framework entity-framework-core generics
asked by grokky

Check if DbSet<T> is empty

I am working on a method to seed an EF Core database from json. As such, I have a series of methods that function as desired like below for each entity (...FilterList... and ...Language... are the two example entities). These methods are all identical exc...
.net c# entity-framework entity-framework-core generics
asked by Collin M. Barrett

Apply deletes during custom seed of DbSet<T>

I am trying to extend my custom seed routine (I know EF Core 2.1 supports seeding natively, but I have a ...blocker... in converting) to apply deletions. If a record exists in the database, but no longer in the seed data, I want to delete it. Rather than ...
c# entity-framework-core generics linq reflection
asked by Collin M. Barrett

Filtering generic select with changeable parameters

I'll keep it simple. I have an API endpoint that receives 0 to 3 parameters. The get method look like this:...[HttpGet("filtrar")] public ActionResult<List<TipoDocumento>> GetAllPorFiltro(string sigla, int? status, string descricao) { return _tipoDocu...
c# entity-framework-core generics where-clause
asked by Ricardo Sampaio

Entity Framework Core DbContext.RemoveRange and type constraints

This code throws an exception...System.InvalidOperationException: The entity type 'List<..>' was not found. Ensure that the entity type has been added to the model....private static void Update<T>(DbContext context, ICollection<T> existing, ICollection<T>...
c# entity-framework-core generics
asked by kayjtea

Update parent and child collections on generic repository with EF Core

Say I have a ...Sale... class:...public class Sale : BaseEntity //BaseEntity only has an Id { public ICollection<Item> Items { get; set; } } ...And an ...Item... class:...public class Item : BaseEntity //BaseEntity only has an Id { pub...
c# entity-framework-core generics
asked by Gonzalo Lorieto

C# Dotnet core - Issues with implementing generic DBContext in constructor

I am struggling with this coming back from a long layoff....I asked a ...question... regarding the configuring of a DBContext in my generic base repository. Only after a user has logged in can I then construct a connection string so I cannot register a se...
asp.net-core c# entity-framework-core generics
asked by si2030

C# EF Core QueryableExtensions.FirstOrDefaultAsync strange behaviour

I have a generic repository to whom I pass an ...Expression<Func<TEntity, bool>> filter.... For example this expression looks like: ...filterExpr = part => (filter.ProductId != null ? filter.ProductId == part.ProductId : true) && (filter.SerialNum...
c# entity-framework-core expression generics
asked by Buchter

Using an existing expression/func to build out another expression/func

I want to be able to use a generic method to select a property and pass that into the ...Any()... method....private List<TModel> _models; public bool Any<TModel, TProperty>( Expression<Func<TModel, TProperty>> propertySelector, TModel model) { // ....
c# entity-framework-core expression generics lambda
asked by Erik Philips

Passing types to function in c#

I am using .net core 2.1 with entityframework core....I have different models/entities/types defined in my project. e.g. Student, Class, Teacher....I am getting the table data for these models to set in my cache....At the moment, I am doing this;...string...
c# entity-framework-core generics typeof
asked by Haseeb Sd

looking a way to combine these methods in generic way on same return type

I have got below three methods and they are returning same return type and the only difference among these three methods is that the data is getting retrieved from different tables....Below are those methods....public IQueryable<SpaceFunctionType> GetSpac...
.net c# entity-framework-core generics list
asked by Enigma State

Checking Whether Class Implements Generic Interface

I'm using the following generic function to determine whether a class implements a specified interface:...private static bool HasFieldType<TEntity, TInterface>() { return typeof(TInterface).IsAssignableFrom(typeof(TEntity)); } ...This works fine for t...
c# entity-framework-core generics interface
asked by weblar83

Page 1 of 1
  • 1

Prime Library

Performance

  • Entity Framework Extensions
  • Entity Framework Classic
  • Bulk Operations
  • Dapper Plus

Expression Evaluator

  • C# Eval Expression
  • SQL Eval Function
More Projects...

Related

  • EF Extensions Online Benchmark
  • WIN an EF Extensions license
  • EF6 BatchSaveChanges for only $79
Get monthly updates by subscribing to our newsletter!
SUBSCRIBE!