This question is locked. New answers and comments are not allowed.
Hi Folks!
First of all, thanks for all of you that are here reading. If you are not to help me, you are in the need of, so my post might help you ;)
If you are the one that knows how to make that. please, help me out!
I am migrating to Telerik ORM, and I am facing problem on implementing my Generic Repository that I have for Entity Framework.
Please find below my implementation of the IRepository class.
I am facing problems specifically on GetByID, since I could not find the "FIND" method on Open Access ORM, and in EF, this gets by the id(int) provided and recognizes the key property of the class.
Although, if any of you have a suggestion for a better repository implementation, please let me know!
Thanks a lot in advance!
First of all, thanks for all of you that are here reading. If you are not to help me, you are in the need of, so my post might help you ;)
If you are the one that knows how to make that. please, help me out!
I am migrating to Telerik ORM, and I am facing problem on implementing my Generic Repository that I have for Entity Framework.
Please find below my implementation of the IRepository class.
public
class
Repository<T> : IDisposable, IRepository<T> where T :
class
{
protected
readonly
MaxxDB db =
new
MaxxDB();
public
virtual
void
Create(T item) {
db.Set<T>().Add(item);
db.SaveChanges();
}
public
virtual
void
Remove(T item) {
db.Set<T>().Remove(item);
db.SaveChanges();
}
public
virtual
void
Update(T item) {
db.Entry(item).State = EntityState.Modified;
db.SaveChanges();
}
public
virtual
T GetById(
object
id) {
return
db.Set<T>().Find(id);
}
public
virtual
IQueryable<T> All() {
return
db.Set<T>();
}
public
void
Dispose() {
db.Dispose();
}
}
I am facing problems specifically on GetByID, since I could not find the "FIND" method on Open Access ORM, and in EF, this gets by the id(int) provided and recognizes the key property of the class.
Although, if any of you have a suggestion for a better repository implementation, please let me know!
Thanks a lot in advance!