本文整理汇总了C#中ECustoms.DAL.dbEcustomEntities.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# dbEcustomEntities.Dispose方法的具体用法?C# dbEcustomEntities.Dispose怎么用?C# dbEcustomEntities.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ECustoms.DAL.dbEcustomEntities
的用法示例。
在下文中一共展示了dbEcustomEntities.Dispose方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateVehicle
/// <summary>
/// Update Vehicle
/// </summary>
/// <param name="vehicle"></param>
/// <param name="declerationID"></param>
/// <returns></returns>
public static int UpdateVehicle(tblVehicle vehicle, long declerationID)
{
// Set last modified date to now
vehicle.ModifiedDate = CommonFactory.GetCurrentDate();
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
switch (declerationID)
{
case 0:
{
// Get orgin vehicle
var vehicleOrgin = db.tblVehicles.Where(g => g.VehicleID == vehicle.VehicleID).FirstOrDefault();
if (vehicleOrgin != null)
{
db.Attach(vehicleOrgin);
db.ApplyPropertyChanges("tblVehicles", vehicle);
if (vehicle.ListVehicleChangeGood != null)
{
//update tblVehicleChange
VehicleFactory.DeleteVehicleChangeByVehicleId(vehicle.VehicleID);
VehicleFactory.AddVehicleChangeByVehicleId(vehicle.VehicleID, vehicle.ListVehicleChangeGood.Select(x => x.VehicleId).ToList());
}
db.Connection.Close();
int re = db.SaveChanges();
return re;
}
return -1;
}
default:
{
var vehicleOrgin = db.tblVehicles.Where(g => g.VehicleID == vehicle.VehicleID).FirstOrDefault();
db.Attach(vehicleOrgin);
db.ApplyPropertyChanges("tblVehicles", vehicle);
//db.SaveChanges();
// Insert to tblVehicleDeclerateion
var vehicleDeclara = new tblDeclarationVehicle();
vehicleDeclara.VehicleID = vehicle.VehicleID;
vehicleDeclara.DeclarationID = declerationID;
db.AddTotblDeclarationVehicles(vehicleDeclara);
int re = db.SaveChanges();
db.Connection.Close();
db.Dispose();
return re;
}
}
}