public virtual BprOperationResult <IQueryable <TEntity> > GetAllAsTracking() { try { var result = Table.AsTracking(); return(BprOperationResult <IQueryable <TEntity> > .Success(result)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <IQueryable <TEntity> > .Fail(e)); } }
public virtual BprOperationResult <IQueryable <TEntity> > GetAllAsNoTracking(Expression <Func <TEntity, bool> > expression) { try { var result = Table.Where(expression).AsNoTracking(); return(BprOperationResult <IQueryable <TEntity> > .Success(result)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <IQueryable <TEntity> > .Fail(e)); } }
public virtual BprOperationResult DeleteList(IList <TEntity> entities) { try { Table.RemoveRange(entities); return(BprOperationResult.Success()); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult.Fail(e)); } }
public virtual BprOperationResult <TEntity> Delete(TEntity entity) { try { var result = Table.Remove(entity); return(BprOperationResult <TEntity> .Success(result.Entity)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <TEntity> .Fail(e)); } }
public virtual async Task <BprOperationResult <int> > SaveChangesAsync() { try { var result = await Database.SaveChangesAsync(); return(BprOperationResult <int> .Success(result)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <int> .Fail(e)); } }
public virtual async Task <BprOperationResult <bool> > IsExistsAsync(Expression <Func <TEntity, bool> > expression) { try { var result = await Table.AnyAsync(expression); return(BprOperationResult <bool> .Success(result)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <bool> .Fail(e)); } }
public virtual async Task <BprOperationResult> AddListAsync(IList <TEntity> entities) { try { await Table.AddRangeAsync(entities); return(BprOperationResult.Success()); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult.Fail(e)); } }
public virtual async Task <BprOperationResult <TEntity> > AddAsync(TEntity entity) { try { var result = await Table.AddAsync(entity); return(BprOperationResult <TEntity> .Success(result.Entity)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <TEntity> .Fail(e)); } }
public virtual async Task <BprOperationResult> DeleteListAsync(Expression <Func <TEntity, bool> > expression) { try { var entities = GetAll(expression); if (!entities.IsSucceeded) { return(BprOperationResult.Fail(entities.Exception)); } Table.RemoveRange(await entities.Data.ToListAsync()); return(BprOperationResult.Success()); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult.Fail(e)); } }
public virtual async Task <BprOperationResult <TEntity> > DeleteAsync(Expression <Func <TEntity, bool> > expression) { try { var entity = await GetOrNullAsync(expression); if (!entity.IsSucceeded) { return(BprOperationResult <TEntity> .Fail(entity.Exception)); } var result = Table.Remove(entity.Data); return(BprOperationResult <TEntity> .Success(result.Entity)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <TEntity> .Fail(e)); } }
public virtual async Task <BprOperationResult <TEntity> > GetOrNullAsTrackingAsync( Expression <Func <TEntity, bool> > expression) { try { var entities = GetAllAsTracking(); if (!entities.IsSucceeded) { return(BprOperationResult <TEntity> .Fail(entities.Exception)); } var result = await entities.Data.SingleOrDefaultAsync(expression); return(BprOperationResult <TEntity> .Success(result)); } catch (Exception e) { Logger.LogError(e.Message); return(BprOperationResult <TEntity> .Fail(e)); } }