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...
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....
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...
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...
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...
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...
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...
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...
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...
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...
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...
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; }
...
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 ...
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...
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...
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...
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 ...
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...
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...
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...