コード例 #1
0
        /// <summary>
        /// Create a new Organizer object.
        /// </summary>
        /// <param name="organizerId">Initial value of the OrganizerId property.</param>
        /// <param name="name">Initial value of the Name property.</param>
        public static Organizer CreateOrganizer(global::System.Int32 organizerId, global::System.String name)
        {
            Organizer organizer = new Organizer();

            organizer.OrganizerId = organizerId;

            organizer.Name = name;

            return(organizer);
        }
コード例 #2
0
        static void RunExample()
        {
            using (var context = new EFRecipesEntities())
            {
                var org = new Organizer {
                    Name = "Community Charity"
                };
                var evt = new Event {
                    Name = "Fundraiser"
                };
                org.Events.Add(evt);
                context.Organizers.AddObject(org);
                org = new Organizer {
                    Name = "Boy Scouts"
                };
                evt = new Event {
                    Name = "Eagle Scout Dinner"
                };
                org.Events.Add(evt);
                context.Organizers.AddObject(org);
                context.SaveChanges();
            }

            using (var context = new EFRecipesEntities())
            {
                var evsorg1 = from ev in context.Events
                              from organizer in ev.Organizers
                              select new { ev.EventId, organizer.OrganizerId };
                Console.WriteLine("Using nested from clauses...");
                foreach (var pair in evsorg1)
                {
                    Console.WriteLine("EventId {0}, OrganizerId {1}", pair.EventId.ToString(), pair.OrganizerId.ToString());
                }

                var evsorg2 = context.Events.SelectMany(e => e.Organizers, (ev, org) => new { ev.EventId, org.OrganizerId });
                Console.WriteLine("\nUsing SelectManay()");
                foreach (var pair in evsorg2)
                {
                    Console.WriteLine("EventId {0}, OrganizerId {1}", pair.EventId.ToString(), pair.OrganizerId.ToString());
                }
            }

            Console.WriteLine("Press <enter> to continue...");
            Console.ReadLine();
        }
コード例 #3
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Organizers EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToOrganizers(Organizer organizer)
 {
     base.AddObject("Organizers", organizer);
 }