Is it possible to add fields to the entity fields collection?

Posts   
 
    
BexMed
User
Posts: 63
Joined: 18-Jul-2007
# Posted on: 10-Dec-2007 17:58:15   

Hello

The subject pretty much speaks for its self, but to explain a little bit more, I would like to know if it is possible to add fields that aren't in the database to the entityfields collection so I can run queries on them and they are returned in my entity collection.

Thanks

Bex

I am using LLBL v2.5 (Sept 24th 2007), the adapter mode.

BexMed
User
Posts: 63
Joined: 18-Jul-2007
# Posted on: 10-Dec-2007 19:19:47   

I have come across this thread mentioning it..

http://www.llblgen.com/tinyforum/Messages.aspx?ThreadID=9330&HighLight=1

The opener of the thread mentions doing this:

protected override IEntityFields CreateFields() { IEntityFields toReturn = base.CreateFields(); toReturn.Expand(1); IEntityField IsPolicyValid = new EntityField("IsPolicyValid", SqlFunctionFactory.IsPolicyValid(SomeEntityFields.SomeEntityId)); toReturn.DefineField(IsPolicyValid, (int)SomeEntityFieldIndexExt.IsPolicyValid); return toReturn; }

Although you have said that it is not possible to override the base entity, would it be possible to do something like this in one my public properties on mu orderentity?



custom= getValueFromCustomPlace();
                
base.fields.Expand(1);
IEntityField customField= new EntityField("CustomField", custom);
base.fields.DefineField(customField, 0);


Thanks

Bex

goose avatar
goose
User
Posts: 392
Joined: 06-Aug-2007
# Posted on: 10-Dec-2007 20:38:32   

quoting what franz wrote in the end of the thread:

In the SqlServer DQE, you could modify the insert DQ creation routine by adding some code which tests if the field in question has an Expression set. If so, skip the field (inserts need this, for updates it should still work). Be aware that the index is used in both the fields and the persistence info and from that point on doesn't match anymore so you need 2 indexes.