What's all the hype about entities in Entity Framework 4?
I am an EF intermediate user on .net 3.5 and recently migrated to .net 4.
One thing that I look at while reading various tutorials is the use of ObjectSets instead of ObjectQuery and that they are a great new feature.
What's so good about them?
Please enlighten me.
Best regards, Cohan
+2
a source to share
1 answer
Not sure what that means in your question, but what's really cool about ObjectSet is that it implements the IObjectSet interface , which means you can easily fake it and check the code down to the data access layer.
Even colder, since ObjectSet uses generic types ( IObjectSet <T> ), you can have a common repository and implement the Unit Of Work pattern .
public interface IRepository<T> where T : class
{
IQueryable<T> GetQuery();
IEnumerable<T> GetAll();
IEnumerable<T> Find(Func<T, bool> where);
T Single(Func<T, bool> where);
T First(Func<T, bool> where);
void Delete(T entity);
void Add(T entity);
void Attach(T entity);
void SaveChanges();
}
full article here:
+4
a source to share