在实体框架 vs2010 上工作,我想在某处存储从数据库中获取的一组对象。因为我不想在用户请求之后调用 DB。我这样做:
public IEnumerable<Message> Messages {
get { return HttpContext.Session[SESSION_MESSAGES_NAME] as IEnumerable<Message>; }
set { HttpContext.Session[SESSION_MESSAGES_NAME] = value; }
}
objEntity = new CmnItemSpecificationDetail();
objEntity.ItemSpecificationDetailRecordID = hidItemSpecificationDetailRecordID.Value.ToString() == "" ? _ItemSpecificationDetail.Count + 1 : int.Parse(hidItemSpecificationDetailRecordID.Value.ToString());
objEntity.SpecificationID = drpSpecification.SelectedIndex == 0 ? -1 : int.Parse(drpSpecification.SelectedValue);
objEntity.SpecValue = Convert.ToDecimal(txtSpecValue.Text);
objEntity.UOMID = drpUOM.SelectedIndex == 0 ? -1 : int.Parse(drpUOM.SelectedValue);
objEntity.UOMID = 1;
objEntity.Action = Entity.ActionMode.Add;
objEntity.Action = Entity.ActionMode.Add;
objEntity.CreateBy = LogInUser;
objEntity.CreateOn = DateTime.Now;
objEntity.CreatePc = PCName;
Messages.Append(objEntity);//failed to add item
public static class exten
{
public static IEnumerable<T> Append<T>(this IEnumerable<T> source, params T[] items)
{
return source.Concat(items);
}
}
此列表无法填写项目,想知道为什么无法在列表中添加项目,是什么问题,如何解决这个问题。
如果有任何疑问请询问,在此先感谢。