I'm trying to execute a query against multiple columns in EF 6 (using C# WPF on VS 2013), I need to select all fields of some columns. I really don't know much but I already tried to do it with Linq and it doesn't seem to have that functionality, so I went with <context>.Database.SqlQuery<string>(query)
, but it's unclear to me how should I handle what it returns. The query is something simple like "SELECT column1,column2 FROM table"
.
Is it possible to do it with Linq
? How? And for the SqlQuery()
case, How should I handle it's result, being most of its columns are in string format?
context.Table.Select(x => new { x.Column1, x.Column2 });
.