Filtering on custom fields in derived entity?

Posts   
 
    
thnk2wn
User
Posts: 31
Joined: 05-Jul-2008
# Posted on: 11-Nov-2008 14:57:13   

SD.LLBLGen.Pro.ORMSupportClasses.NET20.dll : 2.6.8.1013 SD.LLBLGen.Pro.LinqSupportClasses.NET35.dll : 2.6.8.1110 SD.LLBLGen.Pro.DQE.Oracle10g.NET20.dll : 2.6.8.1009 .NET 3.5, Adapter, General2008, Oracle 9i

See also: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=14529

I have an inherited entity like so...


namespace CRMA.Model.EntityClasses
{
    public class ReviewersAndCodersLookup : ReviewersAndCodersEntity
    {
        private long _billingCenterId;

        public long BillingCenterId
        {
            get { return _billingCenterId; }
            set { _billingCenterId = value; }
        }

        protected override IEntityFactory2 CreateEntityFactory()
        {
            return new ReviewersAndCodersLookupFactory();
        }
    }
}

...and I would like to be able to filter on the custom BillingCenterId property in the derived entity. I have a BindingSource setup with its datasource being an EntityCollection of the derived ReviewersAndCodersLookup...

Problem 1: I assumed I would be able to set BindingSource.Filter but I noticed SupportsFiltering was False. I was thinking the EntityView (via collection.DefaultView) would give me this support but it appears not. Instead it appears I must go through the Filter property of the EntityView using a predicate expression?

Problem 2: Assuming #1 is true, I attempted the predicate filter route but how do I set that up if there is no field for the property I want to filter on in the derived entity? I am assuming I cannot? Would I need to create a field in code or how would I go about achieving this?

Thanks

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 11-Nov-2008 21:29:38   

1) Correct - you need to create an Entity view. 2) You can filter on a custom field using and EntityProperty. Please see the documentation at

http://www.llblgen.com/documentation/2.6/Using%20the%20generated%20code/Adapter/gencode_usingentityview_adapter.htm#multiclausefiltering

thnk2wn
User
Posts: 31
Joined: 05-Jul-2008
# Posted on: 11-Nov-2008 23:25:26   

Thanks that appeared to do it


        public void FilterByBillingCenterId(decimal billingCenterId)
        {           
            this.ReviewersAndCoders.DefaultView.Filter =
                new DelegatePredicate<ReviewersAndCodersLookup>(
                    c => c.BillingCenterId == billingCenterId);         
        }

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 12-Nov-2008 10:11:24   

HTH simple_smile