cypressnorth / .net-ef6-genericrepository Goto Github PK
View Code? Open in Web Editor NEWA Generic Entity Framework 6 data repository for .NET 4.5 supporting both sync and async methods
License: MIT License
A Generic Entity Framework 6 data repository for .NET 4.5 supporting both sync and async methods
License: MIT License
Since EF5+ automatically attaches an entity whenever it is marked as modified, your code:
TObject existing = await _context.Set<TObject>().FindAsync(key);
if (existing != null)
{
_context.Entry(existing).CurrentValues.SetValues(updated);
await _context.SaveChangesAsync();
}
should be updated to:
_context.Entry(updated).State = EntityState.Modified;
await _context.SaveChangesAsync();
This gives three huge advantages:
a) only one database trip
b) less resource load, because no need for loading the original entity
c) no need for specifying a key, hence no concrete type dependence and a true generic method
Please see this StackOverflow comment for further details.
Hi,
DataContext class are missing lots of methods which are implemented in that BaseService class like Set method, SaveChangesAsync..
Am I missing any reference dll?
where are there?
I am curious why you decided to go with returning list objects vs IQueryables? Without the ability to retrieve IQueryable objects don't you limit access to linq extensions such as Include.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.