Esempio n. 1
0
        static void RunExample()
        {
            byte[] thumbBits = new byte[100];
            byte[] fullBits  = new byte[2000];
            using (var context = new EFRecipesEntities())
            {
                var photo = new Photograph {
                    PhotoId = 1, Title = "My Dog", ThumbnailBits = thumbBits
                };
                var fullImage = new PhotographFullImage {
                    PhotoId = 1, HighResolutionBits = fullBits
                };
                photo.PhotographFullImage = fullImage;
                context.Photographs.AddObject(photo);
                context.SaveChanges();
            }

            using (var context = new EFRecipesEntities())
            {
                foreach (var photo in context.Photographs)
                {
                    Console.WriteLine("Photo: {0}, ThumbnailSize {1} bytes", photo.Title, photo.ThumbnailBits.Length.ToString());

                    // explicitly load the "expensive" entity, PhotographFullImage
                    photo.PhotographFullImageReference.Load();
                    Console.WriteLine("Full Image Size: {0} bytes", photo.PhotographFullImage.HighResolutionBits.Length.ToString());
                }
            }

            Console.WriteLine("Press <enter> to continue...");
            Console.ReadLine();
        }
        /// <summary>
        /// Create a new PhotographFullImage object.
        /// </summary>
        /// <param name="photoId">Initial value of the PhotoId property.</param>
        /// <param name="highResolutionBits">Initial value of the HighResolutionBits property.</param>
        public static PhotographFullImage CreatePhotographFullImage(global::System.Int32 photoId, global::System.Byte[] highResolutionBits)
        {
            PhotographFullImage photographFullImage = new PhotographFullImage();

            photographFullImage.PhotoId = photoId;

            photographFullImage.HighResolutionBits = highResolutionBits;

            return(photographFullImage);
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the PhotographFullImageSet EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPhotographFullImageSet(PhotographFullImage photographFullImage)
 {
     base.AddObject("PhotographFullImageSet", photographFullImage);
 }