call a SQL function as a property of an entity

Posts   
 
    
raduch
User
Posts: 17
Joined: 26-Jan-2007
# Posted on: 21-Jun-2011 11:13:07   

Hi guys,

I use LLBL v2.6 in self servicing mode (with 2 classes) and I want a add a new read only property to an entity and return the result of a stored procedure. Can you post a example how to do this in the best way? I was thinking to use an SqlCommand object but didn't seem like the LLBL style... simple_smile

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14983
Joined: 21-Aug-2005
# Posted on: 21-Jun-2011 11:50:20   

You can map this SP to LLBLGen funtction call, and perform the call in the get of the property.

raduch
User
Posts: 17
Joined: 26-Jan-2007
# Posted on: 21-Jun-2011 17:05:38   

Is it possible to do in LLBL something like:

select field1, field2, func1(f3) from entity1.....

and get the entity with field f3 mapped as a function in one query or you will end up with 2 queries, one for entity and on to get the result of the function for field f3 like:

select field1, field2, f3 from entity1 and then select func1(f3)

thanks

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 21-Jun-2011 20:52:43   

You can't get it added to the main select if you are fetching entities, you will always end up with 2 SQL calls.

If you are using a DynamicList, you can use a DBFunctionCall to get the call to the function included in the SQL select statement.

Matt

raduch
User
Posts: 17
Joined: 26-Jan-2007
# Posted on: 21-Jun-2011 22:06:37   

Thanks guys.