public virtual ExtendedPrice UpdateExtendedPrice(ExtendedPrice entity) { if (entity.IsTransient()) { return(entity); } ExtendedPrice other = GetExtendedPrice(entity.ExtendedPriceId); if (entity.Equals(other)) { return(entity); } string sql = @"Update ExtendedPrice set [ExtendedPriceGUID]=@ExtendedPriceGUID , [VariantID]=@VariantID , [CustomerLevelID]=@CustomerLevelID , [Price]=@Price , [ExtensionData]=@ExtensionData , [CreatedOn]=@CreatedOn where ExtendedPriceID=@ExtendedPriceID" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@ExtendedPriceID", entity.ExtendedPriceId) , new SqlParameter("@ExtendedPriceGUID", entity.ExtendedPriceGuid) , new SqlParameter("@VariantID", entity.VariantId) , new SqlParameter("@CustomerLevelID", entity.CustomerLevelId) , new SqlParameter("@Price", entity.Price) , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value) , new SqlParameter("@CreatedOn", entity.CreatedOn) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetExtendedPrice(entity.ExtendedPriceId)); }
public virtual ExtendedPrice InsertExtendedPrice(ExtendedPrice entity) { ExtendedPrice other = new ExtendedPrice(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into ExtendedPrice ( [ExtendedPriceGUID] ,[VariantID] ,[CustomerLevelID] ,[Price] ,[ExtensionData] ,[CreatedOn] ) Values ( @ExtendedPriceGUID , @VariantID , @CustomerLevelID , @Price , @ExtensionData , @CreatedOn ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@ExtendedPriceID", entity.ExtendedPriceId) , new SqlParameter("@ExtendedPriceGUID", entity.ExtendedPriceGuid) , new SqlParameter("@VariantID", entity.VariantId) , new SqlParameter("@CustomerLevelID", entity.CustomerLevelId) , new SqlParameter("@Price", entity.Price) , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value) , 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(GetExtendedPrice(Convert.ToInt32(identity))); } return(entity); }