Hi,
I am creating a grid that will be generated dynamically to perform general table lookups in our system. We simply pass the name of the EntityFactory that we want to view in the LLBL's DataSource EntityFactoryTypeName, and that all work great.
However, I need to be able to search through the fields in the table to see if a certain field exists, and if it does I need to add a filter to the datasource.
Here is what I have so far:
EntityFactoryBase2 ef = new FrameworkUserEntityFactory();
IEntityFields2 eflds = ef.CreateFields();
foreach (EntityField2 efld in eflds)
{
if (efld.Name == "ClientID")
{
IPredicate filter;
filters.PredicateExpression.Add(FrameworkUserFields.ClientId == ClientID);
// ADD ClientID filter to datasource
}
}
My first problem is the first line, which is presently hardcoded to create a specific EntityFactory (FramworkUser). I need to change this line so that it creates an entity factory as specified in the datasource EntityFactoryTypeName property. I assume I need to use reflection to do this, but I'm not familiar with how. Can anyone point me in the right direction?
My second problem is the PredicateExpression.Add line, which is again presently hardcoded to a specific entity's Fields class. Again any feedback on how I can access the Fields class for an entity specified by the datasource EntityFactoryTypeName property would be appreciated.
Thanks.