如何从实体框架中读取?
我用它来插入项目:
public void Insert()
{
using (HistoryContainer db = new HistoryContainer())
{
HistoryData e = new HistoryData();
e.MP = IpAddress;
e.Number = OtherPartyNumber;
e.DateTimeStart = DateTime.Now;
e.Duration = duration;
e.TypeDescription = type;
e.text = e.text;
db.AddToHistoryDataSet(e);
db.SaveChanges();
}
}
我试过这个来阅读它们:
public virtual IEnumerable<HistoryContainer> ReadFirst()
{
using (HistoryContainer x = new HistoryContainer())
{
foreach (var item in HistoryData.where(b => b.MP == IpAddress))
{
_history.Add(new HistoryItem(item));
}
}
}
但它没有用。怎么了?谢谢。