public void printElements() { using (var context = new Photographs()) { foreach (var p in context.Photos) { Console.WriteLine("Photo : {0} , ThumbnailSize {1} bytes", p.Title, p.ThumbnailBits.Length); context.Entry(p) .Reference(ph => ph.PhotographFullImage).Load(); Console.WriteLine("Full Image Size: {0} bytes", p.PhotographFullImage.HighResolutionBits.Length); } } }
public void addElement(string title, byte[] thumbBits, byte[] fullBits) { using (var context = new Photographs()) { var photo = new Photograph { Title = title, ThumbnailBits = thumbBits }; var fullImage = new PhotographFullImage { HighResolutionBits = fullBits, }; photo.PhotographFullImage = fullImage; context.Photos.Add(photo); context.SaveChanges(); } }