Suppose I have a generic data access layer method for updating records with something like this code:
public virtual void Update<P>(Expression<Func<T, P>> excludeColumn, params T[] items)
{
foreach (T item in items)
{
_entities.Entry(item).State = EntityState.Modified;
_entities.Entry(item).Property(excludeColumn).IsModified = false;
}
_entities.SaveChanges();
}
Here I am taking excludeColumn
param for excluding column from update, and I passed value into this parameter like this
_companyProfileRepository.Update(x => x.EmailAddress, records);
x => x.EmailAddress
is an expression which I pass into the generic Update
method. My problem is I want to pass multiple columns into Update
method, because sometimes I need to exclude more than just one column, but my method doesn't support multiple column mechanism.
Can anyone help me figure this out?