public virtual DocumentCustomerLevel InsertDocumentCustomerLevel(DocumentCustomerLevel entity)
        {
            DocumentCustomerLevel other = new DocumentCustomerLevel();

            other = entity;
            if (entity.IsTransient())
            {
                string         sql            = @"Insert into DocumentCustomerLevel ( [DocumentID]
				,[CustomerLevelID]
				,[CreatedOn] )
				Values
				( @DocumentID
				, @CustomerLevelID
				, @CreatedOn );
				Select scope_identity()"                ;
                SqlParameter[] parameterArray = new SqlParameter[] {
                    new SqlParameter("@DocumentID", entity.DocumentId)
                    , new SqlParameter("@CustomerLevelID", entity.CustomerLevelId)
                    , 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(GetDocumentCustomerLevel(Convert.ToInt32(identity)));
            }
            return(entity);
        }
        public virtual DocumentCustomerLevel UpdateDocumentCustomerLevel(DocumentCustomerLevel entity)
        {
            if (entity.IsTransient())
            {
                return(entity);
            }
            DocumentCustomerLevel other = GetDocumentCustomerLevel(entity.DocumentId);

            if (entity.Equals(other))
            {
                return(entity);
            }
            string sql = @"Update DocumentCustomerLevel set  [CustomerLevelID]=@CustomerLevelID
							, [CreatedOn]=@CreatedOn 
							 where DocumentID=@DocumentID"                            ;

            SqlParameter[] parameterArray = new SqlParameter[] {
                new SqlParameter("@DocumentID", entity.DocumentId)
                , new SqlParameter("@CustomerLevelID", entity.CustomerLevelId)
                , new SqlParameter("@CreatedOn", entity.CreatedOn)
            };
            SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray);
            return(GetDocumentCustomerLevel(entity.DocumentId));
        }