GetObjectByKey in linq to oracle

GetObjectByKey in linq to oracle

Postby tchovis » Tue 20 Apr 2010 20:37

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.
tchovis
 
Posts: 12
Joined: Fri 03 Apr 2009 12:56

Postby AndreyR » Wed 21 Apr 2010 11:33

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().
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

i need a generic one

Postby tchovis » Wed 21 Apr 2010 23:43

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.
tchovis
 
Posts: 12
Joined: Fri 03 Apr 2009 12:56

Postby AndreyR » Thu 22 Apr 2010 11:49

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
AndreyR
Devart Team
 
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Postby bbjosh » Wed 28 Apr 2010 21:58

This link has a SelectByPK() method which can be carefully adapted

http://www.c-sharpcorner.com/UploadFile ... SinCS.aspx
bbjosh
 
Posts: 6
Joined: Fri 07 Nov 2008 19:38


Return to dotConnect for Oracle