public void AddReturn <TEntity>(TEntity entity, out TEntity inserted) where TEntity : class { EFDbContext dbContext = GetEFDbContext <TEntity>(); inserted = dbContext.Set <TEntity>().Add(entity); }
/// <summary> /// Get Entity queryable /// </summary> /// <typeparam name="TEntity"></typeparam> /// <returns></returns> public IQueryable <TEntity> GetQuery <TEntity>() where TEntity : class { EFDbContext dbContext = GetEFDbContext <TEntity>(); return(dbContext.Set <TEntity>()); }
/// <summary> /// Attach the specified entity. /// </summary> /// <typeparam name="TEntity">The type of the entity.</typeparam> /// <param name="entity">The entity.</param> public void Attach <TEntity>(TEntity entity) where TEntity : class { EFDbContext dbContext = GetEFDbContext <TEntity>(); dbContext.Set <TEntity>().Attach(entity); }
/// <summary> /// Add or Updates changes of the existing entity. /// The caller must later call SaveChanges() on the repository explicitly to save the entity to database /// </summary> /// <typeparam name="TEntity">The type of the entity.</typeparam> /// <param name="entity">The entity.</param> public void AddOrUpdate <TEntity>(params TEntity[] entities) where TEntity : class { EFDbContext dbContext = GetEFDbContext <TEntity>(); dbContext.Set <TEntity>().AddOrUpdate(entities); }