本文整理汇总了C#中KM.JXC.DBA.KuanMaiEntities.Entry方法的典型用法代码示例。如果您正苦于以下问题:C# KuanMaiEntities.Entry方法的具体用法?C# KuanMaiEntities.Entry怎么用?C# KuanMaiEntities.Entry使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KM.JXC.DBA.KuanMaiEntities
的用法示例。
在下文中一共展示了KuanMaiEntities.Entry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetDefaultExpress
/// <summary>
///
/// </summary>
/// <param name="express_id"></param>
/// <param name="shop_id"></param>
public void SetDefaultExpress(int express_id,int shop_id=0)
{
if (express_id <= 0)
{
throw new KMJXCException("快递公司不能为空");
}
using (KuanMaiEntities db = new KuanMaiEntities())
{
int[] child_shop = (from c in this.DBChildShops select c.Shop_ID).ToArray<int>();
var tmpNew = from express in db.Express_Shop
where (express.IsDefault == 0 && express.Express_ID==express_id)
select express;
var tmp = from express in db.Express_Shop
where express.IsDefault==1
select express;
if (shop_id > 0)
{
tmp = tmp.Where(t => t.Shop_ID == shop_id);
tmpNew = tmpNew.Where(t => t.Shop_ID == shop_id);
}
else
{
tmp = tmp.Where(t => t.Shop_ID == this.Shop.Shop_ID);
tmpNew = tmpNew.Where(t => t.Shop_ID == this.Shop.Shop_ID);
}
Express_Shop old = tmp.FirstOrDefault<Express_Shop>();
Express_Shop newDefault = tmpNew.FirstOrDefault<Express_Shop>();
if (old != null)
{
old.IsDefault = 0;
old.Modified = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
old.Modified_By = this.CurrentUser.ID;
db.Entry(old).State = System.Data.EntityState.Modified;
//db.Express_Shop.SqlQuery("Update Express_Shop set IsDefault=0 where Express_ID="+old.Express_ID+" and Shop_ID="+old.Shop_ID);
}
if (newDefault != null)
{
newDefault.IsDefault = 1;
newDefault.Modified = DateTimeUtil.ConvertDateTimeToInt(DateTime.Now);
newDefault.Modified_By = this.CurrentUser.ID;
db.Entry(newDefault).State = System.Data.EntityState.Modified;
//db.Express_Shop.SqlQuery("Update Express_Shop set IsDefault=1 where Express_ID=" + newDefault.Express_ID + " and Shop_ID=" + newDefault.Shop_ID);
}
else
{
throw new KMJXCException("设置默认快递公司前,请先确保快递公司已经添加到店铺");
}
db.SaveChanges();
}
}