0

I'm not sure if this is possible but I'm using sqlite and dynamic data structure. Essentially the end user can upload csv files of any type.

So I want to be able to dynamically select a column/s and map to a known type e.g.

 var selectStatement = $"r => new Foo(double.Parse(r.{column}))";
 var whereStatement = $"x => x.{column} != null";

 IQueryable view = data.Where(whereStatemnet).Select(selectStatement).AsQueryable();

However at this point I know the result should be IEnumerable but obviously the compiler doesn't.

I only have a very few base classes that would ever needed to be mapped but unfortunately not all are single column however based on the parameter list I would know... e.g 3 string columns is of type Fizz() and 2 columns could be a Buzz()

Am I going about this wrong way?

Thanks

gumby
  • 137
  • 1
  • 1
  • 8
  • In your data structure are all the data in one field and you trying to say where for example Data !=null get data and then translate into a class Fizz() and Buzz() based on number of parameters in this field? Or are things separated into multiple fields and you just want to query a single table getting Fizz() or Buzz() class based on which columns have data entered? – Lynyrd Apr 10 '20 at 15:34
  • Your'e question is not tagged with [tag:dynamic-linq], so I have to ask: are you trying to use it? if your'e not familiar with it, see example usages [here](https://stackoverflow.com/a/60084895/3002584). – OfirD Apr 19 '20 at 21:19
  • @gumby, did you take a look at the links on my previous comment? do you still need help with your question? – OfirD Apr 21 '20 at 15:36

0 Answers0