hey, thanks a lot for helpful code. I would like to ask you for advice.
I create dynamic reports for entities. So report is entity for sample "Person". And i have another table where i store properties which is available for report filter. For sample "ReportProperty"
what kind of information would be best to store in property table if i want to determine field and his relation?
because i'm writing a dynamic data extractor so i store information about fields in database. So i need to create a column/columns for property relation information. So later i could use reflection or llblgen tools to get relations and field information out and pass it into dao.
So what would be the best to put there?
im thinking about
String relation name and later use reflection get that relation item out?
or
Field name and entity name where is that field from? so later i would scan entities relations and get the specific field relation. using that method what you posted in my later post.
what would you do in this situation, maybe you have better ideas ?
thank you for all help guys.
daelmo wrote:
This is an idea to obtain a 1-level members of a given entityName:
public Dictionary<string, string> GetMembers(string entityName)
{
var factory = EntityFactoryFactory.GetFactory((EntityType)Enum.Parse(typeof(EntityType), entityName));
var entity = factory.Create();
var fieldNames = entity.Fields.Select(f => f.Name);
var navigators = entity.GetAllRelations().Select(r => r.MappedFieldName);
var toReturn = new Dictionary<string, string>();
foreach (var f in fieldNames)
{
toReturn.Add(f, "field");
}
foreach (var n in navigators)
{
toReturn.Add(n, "navigator");
}
return toReturn;
}
You can show that in any .net tree control. Then, if the user click on a node that is a "navigator" you can obtain its type entity name and expand it using the same function, and so on.
If you try to build the full from the beginning you may end up with something like customer->order->shipAddress->customer->order->...