I am using the Linq.Dynamic Library and EF6. I am attempting to select only the fields from a database that my user selects.
However, all that is returned is a List<object>
, I have attempted to Cast<dynamic>
, and every way I can think of, but no matter what the object has 0 fields.
I have also tried explicitly declaring as an IEnumerable
and that too was unsuccessful, and was unable to call .ToList()
, without first calling Cast<T>
which too was unsuccessful.
When converting one of the objects to string
I get: "{filenumber=345400, custom2=, custom3=, custom6=4076995332, custom8=4072121417}"
.
The data is being returned I simply cannot cast it to the appropriate type.
var query = cmax.dbases
.Where(w => statuses.Any(a => w.statusname == a) && portfolios.Any(a => w.portfolio == a))
.Select(string.Format("new ({0})", string.Join(",", fields)))
.Take(Math.Min((int) takeAmount, count - taken));
var take = await query.ToListAsync();
take.ForEach(data => {
var type = take.GetType();
var properties = type.GetProperties();
var propCount = properties.Count();
properties.ToList().ForEach(prop => {
var name = prop.Name;
});
});