1
我怎樣才能得到的數據作爲我的一流的設計如何獲得在類格式的數據與LINQ的
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; }
}
我使用下面的代碼來獲得
db是sqliteconntion串;
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();
請告訴我如何得到這個
'Result'似乎對數據進行類映射到表中的新類,你無法投影到與表映射一起使用的實體。 – Habib
你應該創建一個新的類而不是'Result',並將結果投影到這個類,我的觀點是,你當前的答案不會幫助OP,因爲'Result'被映射到DB實體 – Habib
現在看起來好多了,移除了我的downvote – Habib