private bool BulkInsert(List<ShowBase> sbs, List<STPa> pa, List<STIV> iv, List<STIpc> ic, List<STPR> pr, List<STFML> fml, List<STDT> dt, List<STCPc> cpc) { using (MySqlDataContext db = new MySqlDataContext()) { db.ShowBase.BulkInsertPageSize = 100; db.STDT.BulkInsertPageSize = 100; db.STPa.BulkInsertPageSize = 100; db.STIV.BulkInsertPageSize = 100; db.STPR.BulkInsertPageSize = 100; db.STIpc.BulkInsertPageSize = 100; db.STFML.BulkInsertPageSize = 100; db.STCPc.BulkInsertPageSize = 100; db.ShowBase.BulkInsert(sbs); db.STDT.BulkInsert(dt); db.STPa.BulkInsert(pa); db.STIV.BulkInsert(iv); db.STPR.BulkInsert(pr); db.STIpc.BulkInsert(ic); db.STFML.BulkInsert(fml); db.STCPc.BulkInsert(cpc); db.SubmitChanges(); } return true; }
public static bool AddNewKey(string strKeyName, List <string> _strValues, string strCreatUID) { bool bRs = false; //insert INTO idx_key VALUES(0,0,'212121',1,now());select @@IDENTITY; //BLL.SysMag.Login.StrLoginUserID string strKeyID = DBA.MySqlDbAccess.ExecuteScalar(System.Data.CommandType.Text, string.Format("insert INTO idx_key VALUES(0,0,'{0}',{1},now());select @@IDENTITY;", strKeyName, strCreatUID)).ToString(); if (!string.IsNullOrEmpty(strKeyID)) { List <IDXVAL> idxKeyVal = new List <IDXVAL>(); foreach (string strItem in _strValues) { idxKeyVal.Add(new IDXVAL() { CreateUser = int.Parse(strCreatUID), KeyID = int.Parse(strKeyID), VAL = strItem, Pid = 0, AutoIDXContent = "", CreateTime = DateTime.Now }); } using (MySqlDataContext db = new MySqlDataContext()) { db.IDXVAL.BulkInsertPageSize = 100; db.IDXVAL.BulkInsert(idxKeyVal); db.SubmitChanges(); } bRs = true; } return(bRs); }
private bool BulkInsert(List <ShowBase> sbs, List <STPa> pa, List <STIV> iv, List <STIpc> ic, List <STPR> pr, List <STDT> dt, List <STPNS> pn, List <STAnS> an, List <STDMc> dc) { using (MySqlDataContext db = new MySqlDataContext()) { db.ShowBase.BulkInsertPageSize = 100; db.STDT.BulkInsertPageSize = 100; db.STPa.BulkInsertPageSize = 100; db.STIV.BulkInsertPageSize = 100; db.STPR.BulkInsertPageSize = 100; db.STIpc.BulkInsertPageSize = 100; db.STPNS.BulkInsertPageSize = 100; db.STAnS.BulkInsertPageSize = 100; db.STDMc.BulkInsertPageSize = 100; db.ShowBase.BulkInsert(sbs); db.STDT.BulkInsert(dt); db.STPa.BulkInsert(pa); db.STIV.BulkInsert(iv); db.STPR.BulkInsert(pr); db.STIpc.BulkInsert(ic); db.STPNS.BulkInsert(pn); db.STAnS.BulkInsert(an); db.STDMc.BulkInsert(dc); db.SubmitChanges(); } return(true); }
public static bool AddNewKey(string strKeyName, List<string> _strValues, string strCreatUID) { bool bRs = false; //insert INTO idx_key VALUES(0,0,'212121',1,now());select @@IDENTITY; //BLL.SysMag.Login.StrLoginUserID string strKeyID = DBA.MySqlDbAccess.ExecuteScalar(System.Data.CommandType.Text, string.Format("insert INTO idx_key VALUES(0,0,'{0}',{1},now());select @@IDENTITY;", strKeyName, strCreatUID)).ToString(); if (!string.IsNullOrEmpty(strKeyID)) { List<IDXVAL> idxKeyVal = new List<IDXVAL>(); foreach (string strItem in _strValues) { idxKeyVal.Add(new IDXVAL() { CreateUser = int.Parse(strCreatUID), KeyID = int.Parse(strKeyID), VAL = strItem, Pid = 0, AutoIDXContent = "", CreateTime = DateTime.Now }); } using (MySqlDataContext db = new MySqlDataContext()) { db.IDXVAL.BulkInsertPageSize = 100; db.IDXVAL.BulkInsert(idxKeyVal); db.SubmitChanges(); } bRs = true; } return bRs; }
/// <summary> /// Creates record in table. /// </summary> /// <param name="obj">Object for recording.</param> /// <returns>true if the operation was successful; otherwise, false.</returns> public void Create(T obj) { using (MySqlDataContext dataContext = new MySqlDataContext(sqlConn)) { dataContext.GetTable <T>().InsertOnSubmit(obj); dataContext.SubmitChanges(); } }
private bool BulkInsert(List<ShowBase> sbs) { MySqlDataContext db = new MySqlDataContext(); db.ShowBase.BulkInsertPageSize = 100; db.ShowBase.BulkInsert(sbs); db.SubmitChanges(); sbs.Clear(); return true; }
/// <summary> /// Delete record in table. /// </summary> /// <param name="id">Id of the object to be deleted.</param> /// <returns>true if the operation was successful; otherwise, false.</returns> public void DeleteById(int id) { using (MySqlDataContext dataContext = new MySqlDataContext(sqlConn)) { T obj = dataContext.GetTable <T>().FirstOrDefault(x => x.Id == id); dataContext.GetTable <T>().DeleteOnSubmit(obj); dataContext.SubmitChanges(); } }
public static bool SaveKeyVal(List <IDXKeyVAL> _idxKeyVal) { bool bRs = false; using (MySqlDataContext db = new MySqlDataContext()) { db.IDXKeyVAL.BulkInsertPageSize = 100; db.IDXKeyVAL.BulkInsert(_idxKeyVal); db.SubmitChanges(); } bRs = true; return(bRs); }
/// <summary> /// Update record in table. /// </summary> /// <param name="obj">Object for updating.</param> /// <param name="id">Id of the object to be updated.</param> /// <returns>true if the operation was successful; otherwise, false.</returns> public void Update(T obj, int id) { using (MySqlDataContext dataContext = new MySqlDataContext(sqlConn)) { T oldObj = dataContext.GetTable <T>().FirstOrDefault(x => x.Id == id); Type type = typeof(T); PropertyInfo[] fields = type.GetProperties(); foreach (PropertyInfo field in fields) { if (!field.CanWrite || field.Name == "Id") { continue; } type.GetProperty(field.Name).SetValue(oldObj, type.GetProperty(field.Name).GetValue(obj)); } dataContext.SubmitChanges(); } }
private bool CNBulkInsert(List <ShowBase> sbs, List <STPa> pa, List <STIV> iv, List <STIpc> ic, List <STPR> pr, List <STDT> dt, List <STQY> qy) { using (MySqlDataContext db = new MySqlDataContext()) { db.ShowBase.BulkInsertPageSize = 100; db.STDT.BulkInsertPageSize = 100; db.STPa.BulkInsertPageSize = 100; db.STIV.BulkInsertPageSize = 100; db.STPR.BulkInsertPageSize = 100; db.STIpc.BulkInsertPageSize = 100; db.STQY.BulkInsertPageSize = 100; db.ShowBase.BulkInsert(sbs); db.STDT.BulkInsert(dt); db.STPa.BulkInsert(pa); db.STIV.BulkInsert(iv); db.STPR.BulkInsert(pr); db.STIpc.BulkInsert(ic); db.STQY.BulkInsert(qy); db.SubmitChanges(); } return(true); }
private bool BulkInsert(List<ShowBase> sbs, List<STPa> pa, List<STIV> iv, List<STIpc> ic, List<STPR> pr, List<STDT> dt, List<STPNS> pn, List<STAnS> an, List<STDc> dc) { using (MySqlDataContext db = new MySqlDataContext()) { db.ShowBase.BulkInsertPageSize = 100; db.STDT.BulkInsertPageSize = 100; db.STPa.BulkInsertPageSize = 100; db.STIV.BulkInsertPageSize = 100; db.STPR.BulkInsertPageSize = 100; db.STIpc.BulkInsertPageSize = 100; db.STPNS.BulkInsertPageSize = 100; db.STAnS.BulkInsertPageSize = 100; db.STDc.BulkInsertPageSize = 100; db.ShowBase.BulkInsert(sbs); db.STDT.BulkInsert(dt); db.STPa.BulkInsert(pa); db.STIV.BulkInsert(iv); db.STPR.BulkInsert(pr); db.STIpc.BulkInsert(ic); db.STPNS.BulkInsert(pn); db.STAnS.BulkInsert(an); db.STDc.BulkInsert(dc); db.SubmitChanges(); } return true; }
private bool EPODOCBulkInsert(List<ShowBase> sbs, List<STPa> pa, List<STIV> iv, List<STIpc> ic, List<STPR> pr, List<STFML> fml, List<STDT> dt, List<STCPc> cpc) { using (MySqlDataContext db = new MySqlDataContext()) { db.ShowBase.BulkInsertPageSize = 100; db.STDT.BulkInsertPageSize = 100; db.STPa.BulkInsertPageSize = 100; db.STIV.BulkInsertPageSize = 100; db.STPR.BulkInsertPageSize = 100; db.STIpc.BulkInsertPageSize = 100; db.STFML.BulkInsertPageSize = 100; db.STCPc.BulkInsertPageSize = 100; db.ShowBase.BulkInsert(sbs); db.STDT.BulkInsert(dt); db.STPa.BulkInsert(pa); db.STIV.BulkInsert(iv); db.STPR.BulkInsert(pr); db.STIpc.BulkInsert(ic); db.STFML.BulkInsert(fml); db.STCPc.BulkInsert(cpc); db.SubmitChanges(); } return true; }
private bool CNBulkInsert(List<ShowBase> sbs, List<STPa> pa, List<STIV> iv, List<STIpc> ic, List<STPR> pr, List<STDT> dt, List<STQY> qy) { using (MySqlDataContext db = new MySqlDataContext()) { db.ShowBase.BulkInsertPageSize = 100; db.STDT.BulkInsertPageSize = 100; db.STPa.BulkInsertPageSize = 100; db.STIV.BulkInsertPageSize = 100; db.STPR.BulkInsertPageSize = 100; db.STIpc.BulkInsertPageSize = 100; db.STQY.BulkInsertPageSize = 100; db.ShowBase.BulkInsert(sbs); db.STDT.BulkInsert(dt); db.STPa.BulkInsert(pa); db.STIV.BulkInsert(iv); db.STPR.BulkInsert(pr); db.STIpc.BulkInsert(ic); db.STQY.BulkInsert(qy); db.SubmitChanges(); } return true; }
public static bool SaveKeyVal(List<IDXKeyVAL> _idxKeyVal) { bool bRs = false; using (MySqlDataContext db = new MySqlDataContext()) { db.IDXKeyVAL.BulkInsertPageSize = 100; db.IDXKeyVAL.BulkInsert(_idxKeyVal); db.SubmitChanges(); } bRs = true; return bRs; }