本文整理汇总了C#中ECustoms.DAL.dbEcustomEntities.Attach方法的典型用法代码示例。如果您正苦于以下问题:C# dbEcustomEntities.Attach方法的具体用法?C# dbEcustomEntities.Attach怎么用?C# dbEcustomEntities.Attach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ECustoms.DAL.dbEcustomEntities
的用法示例。
在下文中一共展示了dbEcustomEntities.Attach方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UpdateVehicle
/// <summary>
/// Update Vehicle
/// </summary>
/// <param name="vehicle"></param>
/// <returns></returns>
public static int UpdateVehicle(tblVehicle vehicle )
{
var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
// Get orgin vehicle
var vehicleOrgin = db.tblVehicles.Where(g => g.VehicleID == vehicle.VehicleID).FirstOrDefault();
db.Attach(vehicleOrgin);
db.ApplyPropertyChanges("tblVehicles", vehicle);
return db.SaveChanges();
}
示例2: Update
/// <summary>
/// update declaration
/// </summary>
/// <param name="declaration"></param>
/// <param name="modifiedByID"></param>
/// <returns></returns>
public static int Update(tblDeclaration declaration)
{
var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
declaration.ModifiedDate = DateTime.Now;
// Get orgin object
var objOrginDeclaration = db.tblDeclarations.Where(g => g.DeclarationID.Equals(declaration.DeclarationID)).FirstOrDefault();
db.Attach(objOrginDeclaration);
db.ApplyPropertyChanges("tblDeclarations", declaration);
return db.SaveChanges();
}
示例3: Update
public static int Update(tblVehicleCheck vehicleCheck)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
// Get orgin object
var objOrginVehicleCheck = db.tblVehicleChecks.Where(g => g.VehicleCheckID == vehicleCheck.VehicleCheckID).FirstOrDefault();
db.Attach(objOrginVehicleCheck);
db.ApplyPropertyChanges("tblVehicleChecks", vehicleCheck);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例4: Update
public static int Update(tblGroup group)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
var groupOrgin = db.tblGroups.Where(g => g.GroupID == group.GroupID).FirstOrDefault();
if (groupOrgin == null) return -1;
db.Attach(groupOrgin);
db.ApplyPropertyChanges("tblGroups", group);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例5: Update
public static int Update(tblCheck check)
{
check.ModifedDate = CommonFactory.GetCurrentDate();
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
var checkOrgin = db.tblChecks.Where(g => g.CheckID == check.CheckID).FirstOrDefault();
if (checkOrgin == null) return -1;
db.Attach(checkOrgin);
db.ApplyPropertyChanges("tblChecks", check);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例6: Update
public static int Update(tblDeclarationLoan loan)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
loan.ModifiedDate = CommonFactory.GetCurrentDate();
// Get orgin object
var objOrginDeclaration = db.tblDeclarationLoans.Where(g => g.ID.Equals(loan.ID)).FirstOrDefault();
db.Attach(objOrginDeclaration);
db.ApplyPropertyChanges("tblDeclarationLoans", loan);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例7: Update
public static int Update(tblTrain train)
{
var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
train.ModifiedDate = CommonFactory.GetCurrentDate();
var originTrain = _db.tblTrains.Where(g => g.TrainID == train.TrainID).FirstOrDefault();
if (originTrain == null)
{
return -1;
}
_db.Attach(originTrain);
_db.ApplyPropertyChanges("tblTrains", train);
return _db.SaveChanges();
}
示例8: 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;
}
}
}
示例9: Update
/// <summary>
/// Update user
/// </summary>
/// <param name="userInfo">userInfo object</param>
/// <returns>Number of rows are effected</returns>
public static int Update(tblUser userInfo)
{
// Encode password & username
userInfo.Password = Common.Encode(userInfo.Password);
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
var usrOrgin = db.tblUsers.Where(g => g.UserID == userInfo.UserID).FirstOrDefault();
if (usrOrgin == null) return -1;
db.Attach(usrOrgin);
db.ApplyPropertyChanges("tblUsers", userInfo);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}