コード例 #1
0
ファイル: UpdateFirstDefect.cs プロジェクト: gourdon/C-
        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
ファイル: RecreateDatabase.cs プロジェクト: krwhite/sync
        static void Main()
        {
            using (var context = new DefectModelDataContext())
            {
                context.Log = Console.Out;

                context.DeleteDatabase();
                context.CreateDatabase();
            }
        }
コード例 #3
0
ファイル: CleanDatabaseSlowly.cs プロジェクト: krwhite/sync
        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
ファイル: PopulateDatabase.cs プロジェクト: krwhite/sync
        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
ファイル: ShowAllClosedDefects.cs プロジェクト: gourdon/C-
        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
ファイル: DeferredLoading.cs プロジェクト: gourdon/C-
        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);
                }
            }
        }
コード例 #8
0
        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);
                }
            }
        }
コード例 #9
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
                            select new { defect.Summary, subscription.EmailAddress };

                foreach (var entry in query)
                {
                    Console.WriteLine("{0}: {1}", entry.EmailAddress, entry.Summary);
                }
            }
        }
コード例 #10
0
ファイル: CleanDatabaseQuickly.cs プロジェクト: krwhite/sync
        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);
                    }
                }

            }
        }