lubo278 wrote:
MTrinder wrote:
Does your MetaColumn contain some information, or inherit from something, which will allow you to determing the field on which the filter is to be applied ?
If not, I can't see how you could do this - if it does it should be possible to get this information out...
Matt
MetaColumn is** System.Web.DynamicData.MetaColumn** (the filter I want to create is Dynamic Data filter). MetaColumn class contains string name of the "column" in database and link to MetaTable object (which contains name of LLBL entity). In fact it had to be in some point generated from LLBL objects (only there is not obvious mapping between them).
However it does not link directly to LLBL objects. But LLBLGenProDynamicDataSource can use filtering on these MetaColumns (I can't see how it does it). So I hoped there is some magic mapping class which I could use.
The filtering all happens through normal SelectParameter elements like with normal datasource controls.
The MetaColumn objects are produced by Dynamic Data from the meta information provided to it by the Dynamic data model provider located in the DynamicDataSupportClasses.
the MetaColumn's Table property provides the MetaTable object, which contains the EntityType value, which is the type of the entity, the name of the entity, and for example a reference to the Model. Using the EntityType, you can obtain an entity instance, or use the type with the generated EntityFactoryFactory (
) type to obtain a factory for the entity at hand.
With the factory (or the entity instance, i'd use the factory), you can create a new entity instance. With that instance you can obtain the field with name MetaColumn.Name
So what you could do is create a utility method which receives a MetaColumn, grabs its Table property, then grab that one's EntityType type, pass that to the EntityFactoryFactory (generated class in FactoryClasses), to create a new Entity instance and obtain the field by using entity.Fields[MetaColumn.Name]
You can THEN pass that field in the predicate:
return new PredicateExpression(obtainedentityField > DateTime.Now.AddMonths(-6));