Beispiel #1
0
        public virtual AspdnsfSysLog UpdateAspdnsfSysLog(AspdnsfSysLog entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            AspdnsfSysLog other = GetAspdnsfSysLog(entity.SysLogId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update aspdnsf_SysLog set  [SysLogGUID]=@SysLogGUID
							, [Message]=@Message
							, [Details]=@Details
							, [Type]=@Type
							, [Severity]=@Severity
							, [CreatedOn]=@CreatedOn 
							 where SysLogID=@SysLogID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@SysLogID", entity.SysLogId)
                , new SqlParameter("@SysLogGUID", entity.SysLogGuid)
                , new SqlParameter("@Message", entity.Message)
                , new SqlParameter("@Details", entity.Details ?? (object)DBNull.Value)
                , new SqlParameter("@Type", entity.Type)
                , new SqlParameter("@Severity", entity.Severity)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetAspdnsfSysLog(entity.SysLogId));
        }
Beispiel #2
0
        public virtual AspdnsfSysLog InsertAspdnsfSysLog(AspdnsfSysLog entity)
        {
            AspdnsfSysLog other = new AspdnsfSysLog();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into aspdnsf_SysLog ( [SysLogGUID]
				,[Message]
				,[Details]
				,[Type]
				,[Severity]
				,[CreatedOn] )
				Values
				( @SysLogGUID
				, @Message
				, @Details
				, @Type
				, @Severity
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@SysLogID", entity.SysLogId)
                    , new SqlParameter("@SysLogGUID", entity.SysLogGuid)
                    , new SqlParameter("@Message", entity.Message)
                    , new SqlParameter("@Details", entity.Details ?? (object)DBNull.Value)
                    , new SqlParameter("@Type", entity.Type)
                    , new SqlParameter("@Severity", entity.Severity)
                    , new SqlParameter("@CreatedOn", entity.CreatedOn)
                };
                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(GetAspdnsfSysLog(Convert.ToInt32(identity)));
            }
            return(entity);
        }