New property based on other entities

Posts   
 
    
raduch
User
Posts: 17
Joined: 26-Jan-2007
# Posted on: 04-Oct-2010 08:34:18   

Hi guys, I use adapter on a CF application and I want to add a custom property that will result from a collection of other entities. Something like this:

public int CurrentMileage { get { ............. EntityCollection<VehicleMileageEntity> controles = new EntityCollection<VehicleMileageEntity>();

                RelationPredicateBucket bucket = new RelationPredicateBucket();
                IPredicateExpression filter = new PredicateExpression();
                filter.Add(VehicleMileageFields.VehicleId == this.VehicleId);

                //IPrefetchPath2 prefech = new PrefetchPath2((int)EntityType.ControlesEntity);
                //prefech.Add(ControlesEntity.PrefetchPathMeasurements);

                //          SortClause sort = new SortClause(ControlesFields.DateCreated, SortOperator.Descending);
                SortExpression sortExp = new SortExpression();
                sortExp.Add(VehicleMileageFields.DateCreated | SortOperator.Descending);

            ** //DataAccessAdapter _adapter = null;
                //try
                //{
                //  _adapter = new DataAccessAdapter(Config.Instance.ConnectionString, true);
                //  _adapter.OpenConnection();
                //   _adapter.FetchEntityCollection(controles, bucket, 1, sortExp, prefech);
                //}**
                //catch (Exception ex)
                //{
                //  Logger.LogException(ex);
                //}

             ......

            }
        }
    }

The problem is that the DataAccessAdapter cannot be access in this project (it is located in the DataLayetDbSpecific project). Is there another way to accomplish this with adapter and CF?

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-Oct-2010 09:54:30   

Why do you need to add this property?

Explain your needs and the usage of it, so we can guide you to the best approach.

raduch
User
Posts: 17
Joined: 26-Jan-2007
# Posted on: 04-Oct-2010 14:51:05   

I think this functionality can be put in a business method as well, but I wanted to know if there is a possibility to work with llbl entities inside a custom member of a llbl entity.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 04-Oct-2010 16:19:54   

Yes you can.

Please check the Extending the CustomerEntityFactory section of this blog post: http://weblogs.asp.net/fbouma/archive/2006/06/09/LLBLGen-Pro-v2.0-with-ASP.NET-2.0.aspx

And here is a relative thread: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=10287

raduch
User
Posts: 17
Joined: 26-Jan-2007
# Posted on: 05-Oct-2010 08:33:07   

Thanks, this is very helpful.