public virtual SystemEventLog UpdateSystemEventLog(SystemEventLog entity) { if (entity.IsTransient()) { return(entity); } SystemEventLog other = GetSystemEventLog(entity.EventLogId); if (entity.Equals(other)) { return(entity); } string sql = @"Update SystemEventLog set [EventCode]=@EventCode , [Title]=@Title , [Description]=@Description , [DateOccured]=@DateOccured , [ElmahErrorID]=@ElmahErrorID , [Source]=@Source where EventLogID=@EventLogID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@EventCode", entity.EventCode ?? (object)DBNull.Value) , new SqlParameter("@Title", entity.Title ?? (object)DBNull.Value) , new SqlParameter("@Description", entity.Description ?? (object)DBNull.Value) , new SqlParameter("@DateOccured", entity.DateOccured) , new SqlParameter("@ElmahErrorID", entity.ElmahErrorId ?? (object)DBNull.Value) , new SqlParameter("@Source", entity.Source ?? (object)DBNull.Value) , new SqlParameter("@EventLogID", entity.EventLogId) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetSystemEventLog(entity.EventLogId)); }
public virtual SystemEventLog InsertSystemEventLog(SystemEventLog entity) { SystemEventLog other = new SystemEventLog(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into SystemEventLog ( [EventCode] ,[Title] ,[Description] ,[DateOccured] ,[ElmahErrorID] ,[Source] ) Values ( @EventCode , @Title , @Description , @DateOccured , @ElmahErrorID , @Source ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@EventCode", entity.EventCode ?? (object)DBNull.Value) , new SqlParameter("@Title", entity.Title ?? (object)DBNull.Value) , new SqlParameter("@Description", entity.Description ?? (object)DBNull.Value) , new SqlParameter("@DateOccured", entity.DateOccured) , new SqlParameter("@ElmahErrorID", entity.ElmahErrorId ?? (object)DBNull.Value) , new SqlParameter("@Source", entity.Source ?? (object)DBNull.Value) }; 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(GetSystemEventLog(Convert.ToInt32(identity))); } return(entity); }
public virtual SystemEventLog UpdateSystemEventLog(SystemEventLog entity) { if (entity.IsTransient()) return entity; SystemEventLog other = GetSystemEventLog(entity.EventLogId); if (entity.Equals(other)) return entity; string sql=@"Update SystemEventLog set [EventCode]=@EventCode , [Title]=@Title , [Description]=@Description , [DateOccured]=@DateOccured , [ElmahErrorID]=@ElmahErrorID , [Source]=@Source where EventLogID=@EventLogID"; SqlParameter[] parameterArray=new SqlParameter[]{ new SqlParameter("@EventCode",entity.EventCode ?? (object)DBNull.Value) , new SqlParameter("@Title",entity.Title ?? (object)DBNull.Value) , new SqlParameter("@Description",entity.Description ?? (object)DBNull.Value) , new SqlParameter("@DateOccured",entity.DateOccured) , new SqlParameter("@ElmahErrorID",entity.ElmahErrorId ?? (object)DBNull.Value) , new SqlParameter("@Source",entity.Source ?? (object)DBNull.Value) , new SqlParameter("@EventLogID",entity.EventLogId)}; SqlHelper.ExecuteNonQuery(this.ConnectionString,CommandType.Text,sql,parameterArray); return GetSystemEventLog(entity.EventLogId); }
public virtual SystemEventLog InsertSystemEventLog(SystemEventLog entity) { SystemEventLog other=new SystemEventLog(); other = entity; if(entity.IsTransient()) { string sql=@"Insert into SystemEventLog ( [EventCode] ,[Title] ,[Description] ,[DateOccured] ,[ElmahErrorID] ,[Source] ) Values ( @EventCode , @Title , @Description , @DateOccured , @ElmahErrorID , @Source ); Select scope_identity()"; SqlParameter[] parameterArray=new SqlParameter[]{ new SqlParameter("@EventCode",entity.EventCode ?? (object)DBNull.Value) , new SqlParameter("@Title",entity.Title ?? (object)DBNull.Value) , new SqlParameter("@Description",entity.Description ?? (object)DBNull.Value) , new SqlParameter("@DateOccured",entity.DateOccured) , new SqlParameter("@ElmahErrorID",entity.ElmahErrorId ?? (object)DBNull.Value) , new SqlParameter("@Source",entity.Source ?? (object)DBNull.Value)}; 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 GetSystemEventLog(Convert.ToInt32(identity)); } return entity; }