Exemplo n.º 1
0
        /// <summary>
        /// create a new entity
        /// </summary>
        /// <param name="entity">entity to create</param>
        /// <returns>number of affected rows</returns>
        public int Create(LudothekEntities context, TEntity entity)
        {
            context.Set <TEntity>().Add(entity);

            var numberOfAffectedRows = context.SaveChanges();

            return(numberOfAffectedRows);
        }
Exemplo n.º 2
0
        /// <summary>
        /// delete article and his articlecultures by id
        /// </summary>
        /// <returns>number of affected entries.</returns>
        public int Delete(LudothekEntities context, TEntity entity)
        {
            context.Set <TEntity>().Remove(entity);

            return(context.SaveChanges());
        }
Exemplo n.º 3
0
        /// <summary>
        /// Get all entities
        /// </summary>
        /// <param name="expression">expression for find a specified entity. Default value null returns all entities</param>
        /// <returns>a list of entities</returns>
        public IQueryable <TEntity> Read(LudothekEntities context, Expression <Func <TEntity, bool> > expression = null)
        {
            var query = expression != null?context.Set <TEntity>().Where(expression) : context.Set <TEntity>();

            return(query);
        }