Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> FieldCompareSet filter referencing the primary table
 

Pages: 1
LLBLGen Pro Runtime Framework
FieldCompareSet filter referencing the primary table
Page:1/1 

  Print all messages in this thread  
Poster Message
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
67 posts
# Posted on: 23-Sep-2019 23:43:23.  
I need to build something like this:
Code:

select * from table1 t1
where
t1.field1=2 and
not exists(select t2.field2 from table1 t2 where t2.field1=1 and t1.field4=t2.field4)


How do I build a FieldCompareSet predicate where the filter uses values from the records being selected (the "t1.field4=t2.field4" part, where t1 and t2 are the same table)?

I know the FieldCompareSet takes an alias but that only works when there's a relation collection, which there isn't in this case.
  Top
Walaa
Support Team



Location:

Joined on:
21-Aug-2005 16:03:48
Posted:
14529 posts
# Posted on: 25-Sep-2019 01:59:53.  
Here is an example:
Code:

select * from Orders
Where ShipVia = 3
and not exists(select O.OrderID from Orders O where O.ShipVia = 1 and CustomerID = O.CustomerID)

Code:

var orders = new EntityCollection<OrderEntity>();

var innerFilter = new PredicateExpression(OrderFields.ShipVia.SetObjectAlias("O") == 1);
innerFilter.Add(OrderFields.CustomerId == OrderFields.CustomerId.SetObjectAlias("O"));

var filterBucket = new RelationPredicateBucket(OrderFields.ShipVia == 3);
filterBucket.PredicateExpression.Add(
    new PredicateExpression(
        new FieldCompareSetPredicate(
            null,
            null,
            OrderFields.OrderId.SetObjectAlias("O"),
            null,
            SetOperator.Exist,
            innerFilter,
            true)));

using (var adapter = new DataAccessAdapter())
{                
    adapter.FetchEntityCollection(orders, filterBucket);
}


  Top
ww
User



Location:

Joined on:
01-Oct-2004 22:58:25
Posted:
67 posts
# Posted on: 25-Sep-2019 03:00:23.  
Thanks! I never knew the fields had the SetObjectAlias function Regular Smiley
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.