Page 1 of 1
GetObjectByKey in linq to oracle
Posted: Tue 20 Apr 2010 20:37
by tchovis
I need one method like the GetObjectByKey and the TryGetObjectByKey from the entityframework to use with Linq to oracle there is any alternative or work around?
i'm trying to make a generic metod for mu bll clas to get object by PK because os that i need this method.
Posted: Wed 21 Apr 2010 11:33
by AndreyR
I recommend you to use
Code: Select all
ContextInstance.MyEntityCollection.Where(entity=>entity.Id == Id).Single();
to replace GetObjectByKey() and
Code: Select all
ContextInstance.MyEntityCollection.Where(entity=>entity.Id == Id).SingleOrDefault();
to replace TryGetObjectByKey().
i need a generic one
Posted: Wed 21 Apr 2010 23:43
by tchovis
i need a generic method not like this one
as you can see in this post
http://thedatafarm.com/blog/data-access ... le-entity/
i wish i could do the same to achieve one genic method for all my entities to find one object by key.
Posted: Thu 22 Apr 2010 11:49
by AndreyR
We will investigate the possibility of adding such methods in one of future builds.
As a temporary workaround you can try Dynamic Linq:
http://weblogs.asp.net/scottgu/archive/ ... brary.aspx
Posted: Wed 28 Apr 2010 21:58
by bbjosh
This link has a SelectByPK() method which can be carefully adapted
http://www.c-sharpcorner.com/UploadFile ... SinCS.aspx