예제 #1
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                Defect defect = context.Defects
                                       .Where(d => d.ID==1)
                                       .Single();

                User tim = defect.CreatedBy;

                defect.AssignedTo = tim;
                tim.Name = "Timothy Trotter";
                defect.Status = Status.Fixed;
                defect.LastModified = SampleData.May(31);

                context.SubmitChanges();
            }

            using (var context = new DefectModelDataContext())
            {
                Defect d = (from defect in context.Defects
                            where defect.ID==1
                            select defect).Single();

                Console.WriteLine (d);
            }
        }
예제 #2
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                context.DeleteDatabase();
                context.CreateDatabase();
            }
        }
예제 #3
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                context.NotificationSubscriptions.DeleteAllOnSubmit(from subscription in context.NotificationSubscriptions select subscription);
                context.Projects.DeleteAllOnSubmit(from project in context.Projects select project);
                context.Defects.DeleteAllOnSubmit(from defect in context.Defects select defect);
                context.Users.DeleteAllOnSubmit(from user in context.Users select user);

                context.SubmitChanges();
            }
        }
예제 #4
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                context.Defects.InsertAllOnSubmit(SampleData.AllDefects);
                context.NotificationSubscriptions.InsertAllOnSubmit(SampleData.AllSubscriptions);
                context.Users.InsertAllOnSubmit(SampleData.AllUsers);
                context.Projects.InsertAllOnSubmit(SampleData.AllProjects);

                context.SubmitChanges();
            }
        }
예제 #5
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                var query = from defect in context.Defects
                            where defect.Status == Status.Closed
                            select defect;

                foreach (var defect in query)
                {
                    Console.WriteLine(defect);
                }
            }
        }
예제 #6
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                Console.WriteLine("Loading defect");
                var defect = (from bug in context.Defects
                             where bug.Summary.Contains("Welsh")
                             select bug).Single();

                Console.WriteLine("Using Project property...");
                Console.WriteLine("Project={0}", defect.Project.Name);
            }
        }
예제 #7
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                var query = from defect in context.Defects
                            select new { defect.Summary, ProjectName=defect.Project.Name };

                foreach (var entry in query)
                {
                    Console.WriteLine("{0}: {1}", entry.ProjectName, entry.Summary);
                }
            }
        }
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                var query = from user in context.Users
                            let length = user.Name.Length
                            orderby length
                            select new { Name = user.Name, Length = length };

                foreach (var entry in query)
                {
                    Console.WriteLine("{0}: {1}", entry.Length, entry.Name);
                }
            }
        }
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                var query = from defect in context.Defects
                            join subscription in context.NotificationSubscriptions
                                on defect.Project equals subscription.Project
                            select new { defect.Summary, subscription.EmailAddress };

                foreach (var entry in query)
                {
                    Console.WriteLine("{0}: {1}", entry.EmailAddress, entry.Summary);
                }
            }
        }
예제 #10
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                // Delete the contents of the tables
                context.ExecuteCommand("DELETE FROM Defect");
                context.ExecuteCommand("DELETE FROM NotificationSubscription");
                context.ExecuteCommand("DELETE FROM Project");
                context.ExecuteCommand("DELETE FROM DefectUser");
                // Reset the identity columns
                context.ExecuteCommand("DBCC CHECKIDENT('Defect', RESEED, 0)");
                context.ExecuteCommand("DBCC CHECKIDENT('NotificationSubscription', RESEED, 0)");
                context.ExecuteCommand("DBCC CHECKIDENT('Project', RESEED, 0)");
                context.ExecuteCommand("DBCC CHECKIDENT('DefectUser', RESEED, 0)");
            }
        }
예제 #11
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                User tim = (from user in context.Users
                            where user.Name=="Tim Trotter"
                            select user).Single();

                var query = from defect in context.Defects
                            where defect.Status != Status.Closed
                            where defect.AssignedTo == tim
                            select defect.Summary;

                foreach (var summary in query)
                {
                    Console.WriteLine(summary);
                }
            }
        }
예제 #12
0
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                var query = from defect in context.Defects
                            join subscription in context.NotificationSubscriptions
                                 on defect.Project equals subscription.Project
                                 into groupedSubscriptions
                            select new { Defect = defect, Subscriptions = groupedSubscriptions };

                foreach (var entry in query)
                {
                    Console.WriteLine(entry.Defect.Summary);
                    Console.WriteLine(entry.Subscriptions.Count());
                    foreach (var subscription in entry.Subscriptions)
                    {
                        Console.WriteLine("  {0}", subscription.EmailAddress);
                    }
                }

            }
        }