1
如何在實體框架中顯示一些特定的表格列而不是整個表格。如何僅在實體框架中顯示錶的特定列?
using (DataEntities cxt = new DataEntities())
{
notes note = cxt.notes.Where(no => no.id == accID).SingleOrDefault();
return notes;
}
如何在實體框架中顯示一些特定的表格列而不是整個表格。如何僅在實體框架中顯示錶的特定列?
using (DataEntities cxt = new DataEntities())
{
notes note = cxt.notes.Where(no => no.id == accID).SingleOrDefault();
return notes;
}
爲此,我建議你使用視圖模型的類似以下內容: -
notes note = cxt.notes.SingleOrDefault(no => no.id == accID);
var model = new YourViewModel // Your viewModel class
{
ID = note.ID,
PropertyOne = note.PropertyOne, // your ViewModel Property
PropertyTwo = note.PropertyTwo
};
你可以用QueryView做到這一點。 這意味着直接用XML編輯你的模型,因爲沒有設計者支持這個,但是你會得到一個獨立的實體,它的字段比原來的要少。
優點:
缺點: