GetObjectByKey in linq to oracle

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
tchovis
Posts: 12
Joined: Fri 03 Apr 2009 12:56

GetObjectByKey in linq to oracle

Post by 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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by 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().

tchovis
Posts: 12
Joined: Fri 03 Apr 2009 12:56

i need a generic one

Post by 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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by 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

bbjosh
Posts: 6
Joined: Fri 07 Nov 2008 19:38

Post by 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

Post Reply