2 回答

TA貢獻1786條經驗 獲得超11個贊
我建議選擇注釋本身和附加字段。
var notes = from n in myContext.Notes
select new
{
Note= n
NewDate = n.date.ToString("MM/YYYY")
}
因此,您的筆記將包含所有原始筆記以及您在結果中添加的其他屬性。

TA貢獻1824條經驗 獲得超5個贊
您使用 lambda 的查詢:
var fetchedNote = await myDbContext.Notes // get the collection of all Notes
.Where(note => note.ClientChartNoteId == Id) // take only those notes that ...
.Select(note => new // from every remaining note, make one new object
{ // with only the properties you plan to use
Title = note.Title, // some are original values
...
Date = note.Data.ToString(...), // some are calculated values
})
.FirstOrDefaultAsync();
- 2 回答
- 0 關注
- 366 瀏覽
添加回答
舉報