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

Entity Framework 6 - Knowledge Base (KB)

31 results for: in tag: generics

How do I build a Linq Expression Tree that compares against a generic object?

I have an IQueryable and an object of type T....I want to do IQueryable().Where(o => o.GetProperty(fieldName) == objectOfTypeT.GetProperty(fieldName))...so ......public IQueryable<T> DoWork<T>(string fieldName) where T : EntityObject { ... T...
c# entity-framework expression-trees generics linq
asked by JTew

Entity Framework Dynamic Where Clause

I have a query like:...var function = GetSomeExpression(); using (FooModel context = new FooModel()) { var bar = context.Bar.Where(function); } ...I'd like to make a generic method that can execute Where against different Entities in the context....
c# entity-framework generics
asked by blu

Entity Framework Generic Repository Error

I am trying to create a very generic generics repository for my Entity Framework repository that has the basic CRUD statements and uses an Interface. I have hit a brick wall head first and been knocked over. Here is my code, written in a console applica...
c# entity-framework generics repository-pattern
asked by Jeff Ancel

How to handle paging IQueryable with Linq To Entities? (problem with OrderBy)

I am currently building a simple ASP.NET MVC site using Linq to Entities. My first foray into this world was nerd dinner, which is where I found the paginated list code that I am attempting to use. The code looks as follows:...public class PaginatedList<T...
entity-framework generics iqueryable
asked by Sergio

Entity Framework - how do I get the columns?

I wish to get a list of columns names, types and whether the column is a PK of a table object in Entity Framework....How do I do this in C# (4.0) (ideally generically)?...The winning answer will be one that does it efficiently and most importantly generic...
asp.net-mvc-3 c# entity-framework generics
asked by Dan B

How to add an item in a collection using Linq and C#

I have a collection of objects. e.g....List<Subscription> subscription = new List<Subscription> { new Subscription{ Type = "Trial", Type = "Offline", Period = 30 }, new Subscription{ Type = "Free", Type = "Offline", Period = 90 }, new Subsc...
c# entity-framework generics linq
asked by user946393

Differences between .CreateObjectSet<T>, .Set<T>, and .CreateQuery<T>?

I am writing a generic repository for entity framework and am confused as to what the difference between these calls are:...ObjectContext.CreateObjectSet<T> ObjectContext.CreateQuery<T> DbContext.Set<T> ...I want a generic repository that both supports co...
datacontext entity-framework generics
asked by SventoryMang

Generic Find() with Includes Entity Framework

I currently have a complete generic repository but I'm missing one feature and that is to use ...Include()... and ...Find()... together....So now I have:...public E FindById<E>(int id) where E : class { return DataContext.Set<E>().Find(id); } ...call...
c# entity-framework generics
asked by Matija Grcic

Generic expression for where clause - "The LINQ expression node type 'Invoke' is not supported in LINQ to Entities."

I am trying to write a really generic way to load EF entities in batches, using the Contains method to generate a SQL IN statement. I've got it working if I pass the entire expression in, but when I try to build the expression dynamically, I am getting a...
entity-framework expression-trees generics linq linq-to-sql
asked by Randar Puust

Should I be using a Generic Repository with Entity Framework 5?

I'm currently using Entity Framework with a Generic Repository and Unit Of Work Pattern. My Model is similar to the one described in ...this article...I've used Generic Repositories in the past and really enjoyed the global functionality it can provide. H...
c# entity-framework generics unit-of-work
asked by Lando

Convert list of of objects to list of tuple without iterating

I'm trying to add an extra parameter to a list of ef objects to track processing, but I keep running into having to initialize each list item explicitly. What's the correct linq way to do this? Aside from terseness, is there any advantage to a linq syntax...
c# entity-framework generics linq tuples
asked by aldosa

Find a specified generic DbSet in a DbContext dynamically when I have an entity

I have following classes and ...DbContext...:...public class Order:BaseEntity { public Number {get; set;} } Product:BaseEntity; { public Name {get; set;} } public class Context : DbContext { .... public DbSet<Order> Orders { set; get; } ...
c# code-first dbset entity-framework generics
asked by Masoud

Join multiple table using generic repository patten with Entity framework with unit of work

I am developing a web application using MVC4 with Entity framework 5....I have created generic repository for accessing database with unit of work. ...Having the below two repository,...CustomerRepository - Customer table...LibraryRepository - Library ...
entity-framework generics repository unit-of-work
asked by kannan Eswar

When using, VS2013, Entity Framework 6 and WebAPI 2, is using a generic repository and UoW framework overkill?

I am re-examining my implementation of the ...generic unit of work and repository framework.......I am using EF6, and VS2013. As such, VS contains WebAPI controller templates that auto-generate WebAPI 2 OData Controller with Actions, using Entity Framew...
c# entity-framework-6 generic-collections generics
asked by ElHaix

Bounded Context and Generic Repository with Entity Framework and wiring with Simple injector IoC

Been reading a lot on StackOverflow and couldn't find any question/answer exact similar to this one. Try to keep it short. ...My key problem is how to design a Generic Repository when you have several bounded contexts. I have been using Generic repository...
c# entity-framework-6 generics repository-pattern simple-injector
asked by Magnus Backeus

Generic method to retrieve DbSet<T> from DbContext

I'm using the Entity Framework with a large database (made up of more than 200 tables)....Trying to create a generic method that returns the ...DbSet<T>... of a specific table ...T... (i.e. class, which can be ...TableA...)....The entity class that was (a...
c# entity-framework generics
asked by Serge P

Entities in 'Y' participate in the 'FK_Y_X' relationship. 0 related 'X' were found. 1 'X' is expected

I have a ...1..*... relationship between ...X... and ...Y..., where ...X... is the parent. When I try and delete record ...Y... I get the following exception message:...Entities in 'Y' participate in the 'FK_Y_X' relationship. 0 related 'X' were found. 1 ...
c# entity-framework-6 generics
asked by Stuart Blackler

Creating an Async version of a Generic Repository

I have a Generic repository implementing the following interface :...public interface IRepository { IUnitOfWork UnitOfWork { get; } IEnumerable<TEntity> GetWithRawSql<TEntity>(string query, params object[] parameters) where TEntity : class; TEnti...
.net async-await c# entity-framework generics
asked by MHOOS

C# Generic Passing different objects with same properties

I am not sure if what I am doing is possible. I have 2 methods. The body of the 2 methods are exactly identical, however the signature of the method both parameter and return are different. The passed in parameter's properties are changed and the objec...
c# entity-framework-6 generics linq
asked by Zoinky

Check if entity is being tracked by Entity Framework context

I have a code block which checks whether an entity is being tracked by my context. If it is, I need to detach it. This works for a given T type....public virtual async Task<bool> InsertOrUpdate(TE entity) { if (entity.Id == 0 || entity.Id == ModelStat...
c# entity-framework-6 generics
asked by FaNIX

Page 1 of 2
  • 1
  • 2
  • »

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
Save your entities 20× faster with EF Extensions
SaveChanges vs BulkSaveChanges

EF Extensions
Try for free now