public virtual SqlLog UpdateSqlLog(SqlLog entity) { if (entity.IsTransient()) { return(entity); } SqlLog other = GetSqlLog(entity.SqlLogId); if (entity.Equals(other)) { return(entity); } string sql = @"Update SQLLog set [SQLText]=@SQLText , [ExecutedBy]=@ExecutedBy , [ExecutedOn]=@ExecutedOn where SQLLogID=@SQLLogID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@SQLLogID", entity.SqlLogId) , new SqlParameter("@SQLText", entity.SqlText) , new SqlParameter("@ExecutedBy", entity.ExecutedBy) , new SqlParameter("@ExecutedOn", entity.ExecutedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetSqlLog(entity.SqlLogId)); }
public virtual SqlLog InsertSqlLog(SqlLog entity) { SqlLog other = new SqlLog(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into SQLLog ( [SQLText] ,[ExecutedBy] ,[ExecutedOn] ) Values ( @SQLText , @ExecutedBy , @ExecutedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@SQLLogID", entity.SqlLogId) , new SqlParameter("@SQLText", entity.SqlText) , new SqlParameter("@ExecutedBy", entity.ExecutedBy) , new SqlParameter("@ExecutedOn", entity.ExecutedOn) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetSqlLog(Convert.ToInt32(identity))); } return(entity); }