Changed db stuff
This commit is contained in:
@@ -38,7 +38,7 @@ public abstract class BaseRepository<TEntityType> : IRepository<TEntityType> whe
|
||||
}
|
||||
else
|
||||
{
|
||||
var dbEntry = await Get(entity);
|
||||
var dbEntry = await GetIncluded(entity);
|
||||
DbContext.Entry(dbEntry).CurrentValues.SetValues(entity);
|
||||
}
|
||||
|
||||
@@ -46,14 +46,18 @@ public abstract class BaseRepository<TEntityType> : IRepository<TEntityType> whe
|
||||
return entity;
|
||||
}
|
||||
|
||||
public virtual async Task<TEntityType?> Get(TEntityType entity)
|
||||
public virtual async Task<TEntityType?> GetIncluded(TEntityType entity)
|
||||
{
|
||||
var keyValues = GetPrimaryKey(entity);
|
||||
return await Get(keyValues);
|
||||
return await GetIncluded(dbEntity => GetPrimaryKey(dbEntity) == GetPrimaryKey(entity));
|
||||
}
|
||||
|
||||
public virtual async Task<TEntityType?> Get(params object?[]? keyValues)
|
||||
|
||||
public virtual async Task<TEntityType?> GetIncluded(Func<TEntityType, bool> predicate)
|
||||
{
|
||||
return await DbContext.Set<TEntityType>().Include(j => j.DateCreated).FindAsync(keyValues);
|
||||
return GetAllIncludedQueryable().FirstOrDefault(predicate);
|
||||
}
|
||||
|
||||
public virtual async Task<IEnumerable<TEntityType>> GetWhereIncluded(Func<TEntityType, bool> predicate)
|
||||
{
|
||||
return GetAllIncludedQueryable().AsEnumerable().Where(predicate);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user