public TournamentConfService(IMapper mapper, ID_Category DaoCategory, ID_Pool DaoPool, ID_Team DaoTeam, ID_Field DaoField, ID_Player DaoPlayer, ID_Match DaoMatches) { _mapper = mapper; _DaoCategory = DaoCategory; _DaoPool = DaoPool; _DaoTeam = DaoTeam; _DaoField = DaoField; _DaoPlayer = DaoPlayer; _DaoMatches = DaoMatches; }
public virtual void DB_Update(Base originalObject, SqlTransaction tran) { using (var cm = new SqlCommand()) { cm.Connection = tran.Connection; cm.Transaction = tran; SaveToSqlParameters(originalObject, cm.Parameters); string upds = (from SqlParameter p in cm.Parameters where !ID_Field.Equals(p.ParameterName.Substring(1)) select p) .Aggregate("", (current, p) => current + ((current.Length > 0 ? "," : "") + p.ParameterName.Substring(1) + "=" + p.ParameterName)); cm.CommandText = string.Format("UPDATE {0} SET {1} WHERE {2}={3}", new object[] { FillFrom_Table, upds, ID_Field, "@" + ID_Field }); try { cm.ExecuteNonQuery(); } catch (SqlException sex) { Env.WriteSqlToLog(sex, cm); throw sex; } catch (Exception ex) { Env.WriteToLog(ex); throw ex; } finally { cm.Dispose(); } } }
public virtual void DB_Insert(SqlTransaction tran) { using (var cm = new SqlCommand()) { cm.Connection = tran.Connection; cm.Transaction = tran; SaveToSqlParameters(null, cm.Parameters); string cols = ""; string vals = ""; foreach ( SqlParameter p in from SqlParameter p in cm.Parameters where !ID_Field.Equals(p.ParameterName.Substring(1)) select p) { cols += (cols.Length > 0 ? "," : "") + p.ParameterName.Substring(1); vals += (vals.Length > 0 ? "," : "") + p.ParameterName; } cm.CommandText = string.Format("INSERT {0}({1}) VALUES({2})", new object[] { FillFrom_Table, cols, vals }); try { cm.ExecuteNonQuery(); } catch (SqlException sex) { Env.WriteSqlToLog(sex, cm); throw sex; } catch (Exception ex) { Env.WriteToLog(ex); throw ex; } } }