How to get data in class format using Linq

how can i get data as design of my class

public class Fsr { public string formId { get; set; } public string formName { get; set; } [PrimaryKey, AutoIncrement] public int fId { get; set; } public int resultId { get; set; } } public class Taskarray { [PrimaryKey, AutoIncrement] public int taskId {get ;set;} public int resultId { get; set; } } public class Result { [PrimaryKey, AutoIncrement] public int resultId {get; set;} public List<Taskarray> taskarray { get; set; } public List<Fsr> fsr { get; set; } public int rootId { get; set; } } 

I use the code below to get the db - sqliteconntion string;

  var data1 = (from e in db.Table<Result>() from f in db.Table<Fsr>() where f.resultId == e.resultId from t in db.Table<Taskarray>() where t.resultId == e.resultId select new { e, e.taskarray=t, e.fsr=f }).ToList(); 

tell me how i get it

+1
source share
1 answer

Update: as a request for a non-reuse list, you can simply use a specific type without an array

  select new Tuple<Result, Taskarray, Fsr > ( e, t, f ); 

You can use a tuple if you do not want to create a new class to display

  select new Tuple<Result, List<Taskarray>, List<Fsr> > ( e, t.ToList<Taskarray>(), f.ToList<Fsr>() ); 

Find linq example in Tuple Type in C # 4.0


you can try like this, you can create a new class that processes incoming data

 select new Myobject { e= e, taskarray =t, fsr =f } 
+1
source

All Articles