本文整理汇总了C#中ECustoms.DAL.dbEcustomEntities.SaveChanges方法的典型用法代码示例。如果您正苦于以下问题:C# dbEcustomEntities.SaveChanges方法的具体用法?C# dbEcustomEntities.SaveChanges怎么用?C# dbEcustomEntities.SaveChanges使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ECustoms.DAL.dbEcustomEntities
的用法示例。
在下文中一共展示了dbEcustomEntities.SaveChanges方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public static int Update(tblVehicleType vehicletype)
{
var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
_db.Connection.Open();
var _vehicletype = (from vt in _db.tblVehicleTypes
where vt.VehicleTypeID == vehicletype.VehicleTypeID
select vt).First();
_vehicletype.Name = vehicletype.Name;
_vehicletype.Capacity = vehicletype.Capacity;
_vehicletype.Description = vehicletype.Description;
vehicletype.UpdatedDate = CommonFactory.GetCurrentDate();
try
{
if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open();
_db.SaveChanges();
}
catch (Exception ex)
{
return 1;
}
finally
{
if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open();
_db.Connection.Close();
}
return 0;
}
示例2: DeleteByID
/// <summary>
/// Delete Decleration by ID
/// </summary>
/// <param name="declerationID">DeclerationID</param>
/// <returns>Number of rows are effected</returns>
public static int DeleteByID(int declerationID)
{
var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
var declaration = db.tblDeclarations.Where(g => g.DeclarationID == declerationID).FirstOrDefault();
db.DeleteObject(declaration);
return db.SaveChanges();
}
示例3: DeleteByID
/// <summary>
/// Delete vehicle by ID
/// </summary>
/// <param name="vehicleID">Vehicle ID</param>
/// <returns>Number of rows are effected</returns>
public static int DeleteByID(int vehicleID)
{
var db = new dbEcustomEntities(Utilities.Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
var vehicle = db.tblVehicles.Where(g => g.VehicleID == vehicleID).FirstOrDefault();
db.DeleteObject(vehicle);
return db.SaveChanges();
}
示例4: DeleteItem
public bool DeleteItem(string[] itemParams)
{
if (itemParams.Length < 2) return false;
string id = itemParams[0];
string branchId = itemParams[1];
var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
try
{
var deleteItem =
_db.tblPermissionTypes.FirstOrDefault(
item => item.TypeCode == id && item.BranchId == branchId);
if (deleteItem != null)
{
_db.DeleteDirectly(deleteItem);
_db.SaveChanges();
}
return true;
}
catch (Exception exception)
{
LogManager.GetLogger("ECustoms.PermissionTypeFactory").Error(exception.ToString());
throw;
}
finally
{
_db.Connection.Close();
}
}
示例5: DeleteItem
public bool DeleteItem(string[] itemParams)
{
if (itemParams.Length < 3) return false;
int id = itemParams[0].StringToInt();
int verhiceId = itemParams[1].StringToInt();
string branchId = itemParams[2];
var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
try
{
var deleteItem =
_db.tblDeclarationVehicles.FirstOrDefault(
item => item.DeclarationID == id && item.VehicleID == verhiceId && item.BranchId == branchId);
if (deleteItem != null)
{
_db.DeleteDirectly(deleteItem);
_db.SaveChanges();
}
return true;
}
catch (Exception exception)
{
LogManager.GetLogger("ECustoms.DeclarationVehicleFactory").Error(exception.ToString());
throw;
}
finally
{
_db.Connection.Close();
}
}
示例6: BatchInsert
public bool BatchInsert(object[] items)
{
var _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
try
{
_db.Connection.Open();
foreach (object item in items)
{
_db.AddObjectDirectly("tblProfileConfigs", item);
}
_db.SaveChanges();
return true;
}
catch (Exception ex)
{
LogManager.GetLogger("ECustoms.AllFactory").Error(ex.ToString());
throw;
}
finally
{
_db.Connection.Close();
}
return false;
}
示例7: Insert
public static int Insert(tblUserInGroup userGroup)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
db.AddTotblUserInGroups(userGroup);
int re= db.SaveChanges();
db.Connection.Close();
return re;
}
示例8: 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();
}
示例9: Insert
public static int Insert(tblVehicleCheck tblVehicleCheck)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
tblVehicleCheck.CreatedDate = CommonFactory.GetCurrentDate();
db.AddTotblVehicleChecks(tblVehicleCheck);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例10: DeleteUserInGroup
public static int DeleteUserInGroup(int groupID, int userID)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
tblUserInGroup tblUserInGroup = db.tblUserInGroups.Where(g => g.GroupID == groupID && g.UserID == userID).FirstOrDefault();
if(tblUserInGroup != null)
db.DeleteObject(tblUserInGroup);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例11: Insert
public static int Insert(tblGroup group)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
group.CreatedDate = CommonFactory.GetCurrentDate();
group.ModifiedDate = CommonFactory.GetCurrentDate();
db.AddTotblGroups(group);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例12: Delete
public static int Delete(long checkID)
{
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
var check = db.tblChecks.Where(g => g.CheckID == checkID).FirstOrDefault();
if (check == null) return -1;
db.DeleteObject(check);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例13: 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();
}
示例14: Insert
/// <summary>
/// Insert User
/// </summary>
/// <param name="userInfo">UserInfo object</param>
/// <returns>Number of rows are effected</returns>
public static int Insert(tblUser userInfo)
{
// Encode password & username
userInfo.Password = Common.Encode(userInfo.Password);
var db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
db.AddTotblUsers(userInfo);
int re = db.SaveChanges();
db.Connection.Close();
return re;
}
示例15: UpdateSettings
public static bool UpdateSettings(string version, DateTime lastSync, int interval, string syncTime, bool isStartSync)
{
dbEcustomEntities _db = new dbEcustomEntities(Common.Decrypt(ConfigurationManager.ConnectionStrings["dbEcustomEntities"].ConnectionString, true));
try
{
if (_db.Connection.State == ConnectionState.Closed) _db.Connection.Open();
var existing = _db.tblSettings.FirstOrDefault(p => p.Version == version);
if(existing==null)
{
tblSetting setting = new tblSetting();
setting.Version = version;
setting.LastSync = lastSync;
setting.SyncInterval = interval;
setting.SyncTime = syncTime;
setting.IsStartingSync = isStartSync;
_db.AddTotblSettings(setting);
return _db.SaveChanges() > 0;
}
else
{
//existing.Version = version;
existing.LastSync = lastSync;
existing.SyncInterval = interval;
existing.SyncTime = syncTime;
existing.IsStartingSync = isStartSync;
return _db.SaveChanges() > 0;
}
}
catch(Exception e)
{
return false;
}
finally
{
_db.Connection.Close();
}
return false;
}