How to use FieldCompareSetPredicate with a database function call

Posts   
 
    
cds avatar
cds
User
Posts: 20
Joined: 01-Feb-2006
# Posted on: 02-Sep-2009 00:12:59   

Using 2.6 with Adapter...

I have a database function - FnGetAdminListEntries which returns a table of primary keys. I'm wanting to build a query that includes results where a foreign key is in the result list from the function call.

Something like:

bucket.PredicateExpression.AddWithAnd(

and this is the SQL I want to build:

PatientEventFields.FkEventId IN (SELECT * FROM dbo.FnGetAdminListEntries("Param1", ...))

So, I've found the DbFunctionCall class and built is as follows:

var dbFnCall = new DbFunctionCall("dbo.FnGetAdminListEntries", new object[] {"Event", DBNull.Value, criteria.EventListCode});

BUT, I'm having trouble with the syntax of the rest of the code.

Help!

How do I reference the returned primary keys from the function?

Thanks,

Craig

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Sep-2009 07:43:46   

Hi Craig,

AFAIK, you can't do this. How the FnGetAdminListEntries sql code looks like? Any change you translate this to LLBLGen predicates?

David Elizondo | LLBLGen Support Team
cds avatar
cds
User
Posts: 20
Joined: 01-Feb-2006
# Posted on: 02-Sep-2009 10:55:11   

Hi Daelmo

Thanks for the reply - I ended up working around the problem by calling the function via a stored procedure and then using the results of that in a standard FieldSetComparePredicate - not an ideal solution but it works for me.

I guess that I could take the code from the function and convert it into predicates too - that would be another option.

Cheers...

Craig