public Decal GetDecal(int id)
        {
            StashRepository <Decal> repo = new StashRepository <Decal>();

            //return (Decal)repo.FindByKeyWithImages(id);
            return((Decal)repo.FindByKey(id));
        }
示例#2
0
 private static void SimpleDecalDemo()
 {
     using (var context = new TCContext())
     {
         StashRepository <Decal> repo = new StashRepository <Decal>(context);
         Decal decal = (Decal)repo.FindByKeyWithImages(Guid.Parse("3e206a4d-4f27-e911-9c25-001583f52824"));
         //Debug.WriteLine("[Before] Decals.ID #{0}: Reference:=\"{1}\"", decal.ID, decal.Reference);
         //Debug.WriteLine("[Before] Images.ID #{0}: FileName:=\"{1}\"", decal.Images[0].ID, decal.Images[0].FileName);
         decal.Reference = decal.Reference == "FTD72003" ? "FTD72003 Data changed" : "FTD72003";
         //Debug.WriteLine("[After] Decals.ID #{0}: Reference:=\"{1}\"", decal.ID, decal.Reference);
         //decal.Images[0].FileName = decal.Images[0].FileName == null ? "Unknown" : null;
         //Debug.WriteLine("[After] Images.ID #{0}: FileName:=\"{1}\"", decal.Images[0].ID, decal.Images[0].FileName);
         //repo.UpdateDisconnected(decal);   //Will update but will not know original values for History updates...
         context.SaveChanges();
     }
 }
示例#3
0
        private static void SimpleRepoGraphQuery()
        {
            StashRepository <Book> _repo = new StashRepository <Book>(new TCContext());

            using (var context = new TCContext())
            {
                Book book = context.Books
                            .Include(b => b.Location) //Eager Loading
                            .FirstOrDefault(b => b.Title.StartsWith("ABC"));

                //If Location is declared as Virtual EF would load the collection
                //on a lazy basis without explicitly loading...
                Book anotherBook = context.Books
                                   .FirstOrDefault(b => b.Title.StartsWith("Death"));
                //context.Entry(anotherBook).Collection(b => b.Location).Load();
            }
        }
 public DecalManager()
 {
     _repo = new StashRepository <Decal>();
 }