コード例 #1
0
 /// <summary>
 /// The get by id.
 /// </summary>
 /// <param name="id">
 /// The id.
 /// </param>
 /// <returns>
 /// The <see cref="T"/>.
 /// </returns>
 public virtual T GetById(int id)
 {
     using (var dbcontext = new evadb())
     {
         return(dbcontext.Set <T>().FirstOrDefault(p => p.Id == 1));
     }
 }
コード例 #2
0
 /// <summary>
 /// The get all.
 /// </summary>
 /// <returns>
 /// The <see cref="List"/>.
 /// </returns>
 public virtual List <T> GetAll()
 {
     using (var dbcontext = new evadb())
     {
         return(dbcontext.Set <T>().ToList());
     }
 }
コード例 #3
0
 /// <summary>
 /// The create.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <returns>
 /// The <see cref="T"/>.
 /// </returns>
 public virtual T Create(T entity)
 {
     using (var dbcontext = new evadb())
     {
         T createdEntity = dbcontext.Set <T>().Add(entity);
         dbcontext.SaveChanges();
         return(createdEntity);
     }
 }
コード例 #4
0
 /// <summary>
 /// The get all.
 /// </summary>
 /// <returns>
 /// The <see cref="List"/>.
 /// </returns>
 public override List <Project> GetAll()
 {
     using (var dbcontext = new evadb())
     {
         return(dbcontext.Projects
                .Select(e => e)
                .Include("Resources")
                .Include("ChatSubscriptions")
                .ToList());
     }
 }
コード例 #5
0
 /// <summary>
 /// The update.
 /// </summary>
 /// <param name="entity">
 /// The entity.
 /// </param>
 /// <returns>
 /// The <see cref="bool"/>.
 /// </returns>
 public virtual bool Update(T entity)
 {
     try
     {
         using (var dbcontext = new evadb())
         {
             dbcontext.Set <T>().AddOrUpdate(entity);
             dbcontext.SaveChanges();
             return(true);
         }
     }
     catch (Exception)
     {
         return(false);
     }
 }