Passing Entity field information

Posts   
 
    
Posts: 30
Joined: 17-Sep-2006
# Posted on: 14-Sep-2007 14:03:57   

Is there any way to pass the ability to create a particular entity field across methods?

Taking an IEntityField2 parameter isn't any good (supplying EntityClassFields.FieldName as the value) - because I need to use the entity field in several places (so need to be able to create a "fresh" instance of that field).

I've looked at using the EntityFieldFactory, but can only really use the overloaded version of Create that takes string parameters - and then would lose all compile time checking of the values being passed in.

Hope this makes sense... does anyone have any ideas?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 14-Sep-2007 17:18:07   

Hope this makes sense...

Not quite enough for me simple_smile Would you please elaborate more with code samples?

Posts: 30
Joined: 17-Sep-2006
# Posted on: 14-Sep-2007 17:44:40   

So, I've got a helper method, that does a bunch of logic, that I'm trying to share across a bunch of tables that have a common structure (but different data).

public static void GetTags(string[] tags, int maxTags, TypedListBase2 typedList, IEntityRelation mappingRelation, IEntityField2 mappingField) { ... }

In there, I've got some code along the lines of:

IGroupByCollection subGroupByClause = new GroupByCollection(); subGroupByClause.Add(mappingField); subGroupByClause.HavingClause = new PredicateExpression(mappingField.SetAggregateFunction(AggregateFunction.Count) == tags.Length);

Now, I can't use mappingField twice (because SetAggregateFunction affects the field directly) - I need a different instance of mappingField for the Add(mappingField) and for within the HavingClause.

So I need a way of saying "use this mapping field" . At the moment I can only think of passing in a delegate or something that will create the required entity field? Hoping that's a little clearer... but I fear not!

Posts: 254
Joined: 16-Nov-2006
# Posted on: 15-Sep-2007 23:51:57   

If your after a separate instance of the EntityFields object have you tried using the Clone method which performs a deep copy of the field?