public IEnumerable <TEntity> AddRange(IEnumerable <TEntity> entities) { long longId = this.Max <TEntity, long>(e => e.CacheId) + 1; Type entityType = typeof(TEntity); PropertyInfo idProperty = GetIdProperty(entityType); foreach (TEntity entity in entities) { SetEntityKey(idProperty, entity, ref longId); MockEntityList.Add(entity); } return(MockEntityList.ToList()); }
public TEntity Add(TEntity entity) { Type entityType = entity.GetType(); PropertyInfo idProperty = GetIdProperty(entityType); if (idProperty != null) { object key = idProperty.GetValue(entity); TEntity found = FindByKey(key); //if (found != null) //{ // throw new DbUpdateExceptionBase(); //} } MockEntityList.Add(entity); return(entity); }