newbie needs Predicate Help

Posts   
 
    
erwin avatar
erwin
User
Posts: 21
Joined: 18-Feb-2005
# Posted on: 19-Feb-2005 00:00:40   

I just started trying out LLBLGen, was able to do a few selects updates etc, but I cant seem to crank out a GetMulti for the following SQL Statement


SELECT DISTINCT iss.Signature FROM ImportSoftwareSignature iss 
             WHERE iss.Signature NOT IN (SELECT ss.Signature FROM SoftwareSignature ss) 
             ORDER BY iss.Signature

Specifically I did not find out how to declare a FieldCompareSetPredicate where the set contains all rows of another table.

Also I am a bit confused on how to specify DISTINCT and ORDER BY

Thanks for clarifying stuff to a newbie.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 19-Feb-2005 09:51:06   

erwin wrote:

I just started trying out LLBLGen, was able to do a few selects updates etc, but I cant seem to crank out a GetMulti for the following SQL Statement


SELECT DISTINCT iss.Signature FROM ImportSoftwareSignature iss 
             WHERE iss.Signature NOT IN (SELECT ss.Signature FROM SoftwareSignature ss) 
             ORDER BY iss.Signature

Specifically I did not find out how to declare a FieldCompareSetPredicate where the set contains all rows of another table.

Also I am a bit confused on how to specify DISTINCT and ORDER BY

WHERE iss.Signature NOT IN (SELECT ss.Signature FROM SoftwareSignature ss) can be formulated as:


IPredicate filter = new FieldCompareSetPredicate(
    EntityFieldFactory.Create(ImportSoftwareSignatureFieldIndex.Signature),
    EntityFieldFactory.Create(SoftwareSignatureFieldIndex.Signature),
    SetOperator.In,
    null,
    true);

OrderBy can be done as:


SortExpression sorter = new SortExpression(SortClauseFactory.Create(ImportSoftwareSignatureFieldIndex.Signature), SortOperator.Ascending);

To get all ImportSoftwareSignature entities:


ImportSoftwareSignatureCollection signatures = new ImportSoftwareSignatureCollection();
signatures.GetMulti(filter, 0, sorter);

To get a list of only the values in the signature field:


ResultsetFields fields = new ResultsetFields(1);
fields.DefineField(ImportSoftwareSignatureFieldIndex.Signature, 0, "Signature");

DataTable dynamicList = new DataTable();
TypedListDAO dao = new TypedListDAO();
dao.GetMultiAsDataTable(fields, dynamicList, 0, sorter, filter, null, false, null, null, 0, 0);

I specify 'false' for the allowDuplicates parameter in GetMultiAsDataTable, which will insert DISTINCT in the query if possible.

Frans Bouma | Lead developer LLBLGen Pro
erwin avatar
erwin
User
Posts: 21
Joined: 18-Feb-2005
# Posted on: 19-Feb-2005 21:03:54   

Thanks!