How to select certain fields from class with IQueryable?
Solution 1:
What about making an interface:
interface Interface1
{
public string Title { get; set; }
public NestedClassTest NestedObject { get; set; }
}
Implement the interface in you class and let GetObjectData return the interface
public IQueryable GetObjectData(IQueryable<Interface1> data)
{
IQueryable requredDataFields = data.Select();
return requredDataFields;
}
Solution 2:
I solved my problem using model, here steps: 1. Map all data from database into model if you have nested object => use ToList(). 2. Use DynamicLinq library to select certain fields from model as IQuerable.
Hope it helps someone!