I have the following method in a generic base class:
public virtual void Insert(TEntity entity) {
dbSet.Add(entity);
}
My service layer uses the Insert
method to add new records. Now I would like to be able to return a bool, to make sure that it inserted properly. Something like the following:
public virtual int Count {
get {
return dbSet.Count();
}
}
public virtual bool Insert(TEntity entity) {
int count = this.Count;
dbSet.Add(entity);
return this.Count == count + 1;
}
Is there a more elegant way to this? Am I approaching it completely incorrectly? I could do something similar for the Delete method, but how would I check if an Update
has been performed successfully?