DbFunctionCall returning a table; joining in Linq

Posts   
 
    
JeroenMink
User
Posts: 8
Joined: 17-Jul-2009
# Posted on: 12-Jan-2011 19:54:30   

I'd like to call a user-defined database function (thus using DbFunctionCall), and join the result on a LLBLGen generated Entity using Linq.

The database function returns a table (and has to accept a parameter). After joining the results of that function to the Entity i'll return a list of entities. However the only example of the DbFunctionCall i've seen is where it returns only one result (decimal, string, http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/gencode_dbfunctioncall.htm) and not a table. I'm returning a table since the function is using a recursive query and i only need to get back Entities which are part of the 'tree' structure. I'm using LLBLGen 2.6.

Is it at all possible what i want?

Sample data:

function-result:
ID   ParentID
1    NULL
2    1
3    1
4    2

'normal' data on which to join:
ID  Name            ParentID
1    "Name 1"    NULL
2    "Name 2"    1
3    "Name 3"     1
4    "Name 4"     2
5    "Name 5"     NULL

The result after the join should then thus be:
ID  Name            ParentID
1    "Name 1"    NULL
2    "Name 2"    1
3    "Name 3"     1
4    "Name 4"     2

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 13-Jan-2011 06:57:09   

That is not supported. How your function looks like? Is there a chance you can emulate the result in a linq expression?

David Elizondo | LLBLGen Support Team
JeroenMink
User
Posts: 8
Joined: 17-Jul-2009
# Posted on: 13-Jan-2011 08:26:17   

the database function is like this, i don't believe Linq supports something like this.

It recursively gets all organizationalUnit objects, puts them in the OrgUnitRec table based on the parentId column

with OrgUnitRec (id, parentId, typeCode) 
as (
      select id, parentOrganizationalUnitID, organizationalUnitTypeCode
      from organizationalUnit
      where id = @organizationalUnitId
union all
      select r.id, r.parentOrganizationalUnitID, r.organizationalUnitTypeCode
      from organizationalUnit r
            inner join OrgUnitRec base
                  on base.parentId is not null and r.id = base.parentId
)

select *
from OrgUnitRec

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 13-Jan-2011 08:42:28   

Not supported, sorry.

JeroenMink
User
Posts: 8
Joined: 17-Jul-2009
# Posted on: 13-Jan-2011 08:56:58   

ok thanks!