with reference to this post, unfortunately I've some problem again.
In reality, not all my entities contains the same common properties, nonetheless I need to inherit/implement my interface, so, in someone cased the properties are declarative only, otherwise for other case.
Here the problem:
public static IQueryable<T> Create<T>(ObjectContext context)
where T : class, IEntity
{
var query = context.CreateObjectSet<T>().AsQueryable();
return query.Where(x => x.CommonProperties == "some value"); // problem here!!
}
In fact, if neither of my entities (documents) contain common properties or else any of them, the final query will not browsable and an exception will be generated.
I've tried with following code snippet without success:
System.Reflection.PropertyInfo p = query.ElementType.GetProperty("common1");
if (p != null) query = query.Where(x => x.common1 == "value.."); // problem here!!
In this case the p
variable never null
, so my query is destinated to failure..
Help me please..