示例#1
0
文件: File.cs 项目: RainSong/Photo
 public int Add(Model.FileInfo fileInfo)
 {
     using (var dbContext = new DAL.PhotoContext())
     {
         dbContext.Entry(fileInfo).State = EntityState.Added;
         return dbContext.SaveChanges();
     }
 }
示例#2
0
文件: File.cs 项目: RainSong/Photo
        public int Delete(int id)
        {
            using (var dbContext = new DAL.PhotoContext())
            {
                var fileInfo = (from f in dbContext.FileInfos
                                where f.id == id
                                select new Model.FileInfo
                                {
                                    id = f.id
                                }).FirstOrDefault();

                dbContext.Entry(fileInfo).State = EntityState.Deleted;
                return dbContext.SaveChanges();
            }
        }