當前位置: 首頁>>代碼示例>>C#>>正文


C# CodeFirst.TrackerContext類代碼示例

本文整理匯總了C#中Tracker.SqlServer.CodeFirst.TrackerContext的典型用法代碼示例。如果您正苦於以下問題:C# TrackerContext類的具體用法?C# TrackerContext怎麽用?C# TrackerContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


TrackerContext類屬於Tracker.SqlServer.CodeFirst命名空間,在下文中一共展示了TrackerContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: FutureCountTest

        public void FutureCountTest()
        {
            var db = new TrackerContext();

            // build up queries

            string emailDomain = "@battlestar.com";
            var q1 = db.Users
                .Where(p => p.EmailAddress.EndsWith(emailDomain))
                .Future();

            string search = "Earth";
            var q2 = db.Tasks
                .Where(t => t.Summary.Contains(search))
                .FutureCount();

            // should be 2 queries 
            //Assert.AreEqual(2, db.FutureQueries.Count);

            // this triggers the loading of all the future queries
            var users = q1.ToList();
            Assert.IsNotNull(users);

            // should be cleared at this point
            //Assert.AreEqual(0, db.FutureQueries.Count);

            // this should already be loaded
            Assert.IsTrue(((IFutureQuery)q2).IsLoaded);

            int count = q2;
            Assert.AreNotEqual(count, 0);
        }
開發者ID:jwaala,項目名稱:EntityFramework.Extended,代碼行數:32,代碼來源:FutureDbContext.cs

示例2: Delete

 public void Delete()
 {
     var db = new TrackerContext();
     string emailDomain = "@test.com";
     int count = db.Users
         .Delete(u => u.EmailAddress.EndsWith(emailDomain));
 }
開發者ID:dioptre,項目名稱:nkd,代碼行數:7,代碼來源:BatchDbContext.cs

示例3: TestCacheStrategy3

        public void TestCacheStrategy3()
        {
            using (var db = new TrackerContext())
            {
                var role1 = CreateRole("Joe 1");
                var role2 = CreateRole("Joe 2");
                var role3 = CreateRole("Bob 3");
                db.Roles.Add(role1);
                db.Roles.Add(role2);
                db.Roles.Add(role3);

                db.SaveChanges();

                db.Roles.Update(o => o.Name.StartsWith("J"), o => new Role { Description = "Updated joe" }, CacheStrategy.FullClean);

                db.SaveChanges();

                db.Roles.Local.Where(o => o.Id == role1.Id).Should().BeEmpty();
                db.Roles.Local.Where(o => o.Id == role2.Id).Should().BeEmpty();
                db.Roles.Local.Where(o => o.Id == role3.Id).Should().BeEmpty();

                db.Roles.Where(o => o.Name.StartsWith("J") && o.Description != "Updated joe").Should().BeEmpty();
                db.Roles.Where(o => o.Id == role3.Id && o.Description == role3.Name).Should().NotBeEmpty();
            }
        }
開發者ID:fpellet,項目名稱:EntityFramework.Extended,代碼行數:25,代碼來源:UpdateTest.cs

示例4: CreateLog2

        public void CreateLog2()
        {
            AuditConfiguration.Default.IncludeRelationships = true;
            AuditConfiguration.Default.LoadRelationships = true;

            AuditConfiguration.Default.IsAuditable<Task>();
            AuditConfiguration.Default.IsAuditable<User>();

            var db = new TrackerContext();
            var task2 = new Task()
            {
                Id = 1,
                AssignedId = 1,
                CreatedId = 1,
                StatusId = 1,
                PriorityId = 2,
                Summary = "Summary: " + DateTime.Now.Ticks
            };
            db.Tasks.Add(task2);

            var audit = db.BeginAudit();

            var task = db.Tasks.Find(1);
            Assert.IsNotNull(task);

            task.PriorityId = 2;
            task.StatusId = 2;
            task.Summary = "Summary: " + DateTime.Now.Ticks;

            var log = audit.CreateLog();
            Assert.IsNotNull(log);

            string xml = log.ToXml();
            Assert.IsNotNull(xml);
        }
開發者ID:fpellet,項目名稱:EntityFramework.Extended,代碼行數:35,代碼來源:AuditTest.cs

示例5: TestCacheStrategy3

        public void TestCacheStrategy3()
        {
            using (var db = new TrackerContext())
            {
                var role1 = CreateRole("Joe 1");
                var role2 = CreateRole("Joe 2");
                var role3 = CreateRole("Bob 3");
                db.Roles.Add(role1);
                db.Roles.Add(role2);
                db.Roles.Add(role3);

                db.SaveChanges();

                db.Roles.Delete(o => o.Name.StartsWith("J"), CacheStrategy.FullClean);

                db.SaveChanges();

                db.Roles.Local.Where(o => o.Id == role1.Id).Should().BeEmpty();
                db.Roles.Local.Where(o => o.Id == role2.Id).Should().BeEmpty();
                db.Roles.Local.Where(o => o.Id == role3.Id).Should().BeEmpty();

                db.Roles.Where(o => o.Name.StartsWith("J")).Should().BeEmpty();
                db.Roles.Where(o => o.Id == role3.Id).Should().NotBeEmpty();
            }
        }
開發者ID:fpellet,項目名稱:EntityFramework.Extended,代碼行數:25,代碼來源:DeleteTest.cs

示例6: UpdateAsync

 public async void UpdateAsync()
 {
     var db = new TrackerContext();
     string emailDomain = "@test.com";
     int count = await db.Users
         .Where(u => u.EmailAddress.EndsWith(emailDomain))
         .UpdateAsync(u => new User { IsApproved = false, LastActivityDate = DateTime.Now });
 }
開發者ID:ArthurYiL,項目名稱:EntityFramework.Extended,代碼行數:8,代碼來源:BatchDbContext.cs

示例7: GetEntityMapAuditData

        public void GetEntityMapAuditData()
        {
            var db = new TrackerContext();

            var map = db.Audits.ToObjectQuery().GetEntityMap<AuditData>();

            Assert.AreEqual("[dbo].[Audit]", map.TableName);
        }
開發者ID:dioptre,項目名稱:nkd,代碼行數:8,代碼來源:MappingObjectContext.cs

示例8: DeleteAsync

        public async void DeleteAsync()
        {
            var db = new TrackerContext();
            string emailDomain = "@test.com";

            int count = await db.Users
                .Where(u => u.EmailAddress.EndsWith(emailDomain))
                .DeleteAsync();
        }
開發者ID:ArthurYiL,項目名稱:EntityFramework.Extended,代碼行數:9,代碼來源:BatchDbContext.cs

示例9: FromCacheTest

        public void FromCacheTest()
        {
            var db = new TrackerContext();
            var roles = db.Roles.FromCache();
            roles.Should().NotBeEmpty();

            var roles2 = db.Roles.FromCache();
            roles2.Should().NotBeEmpty();
        }
開發者ID:jwaala,項目名稱:EntityFramework.Extended,代碼行數:9,代碼來源:CacheDbContext.cs

示例10: FromCacheFirstOrDefaultTest

        public void FromCacheFirstOrDefaultTest()
        {
            var db = new TrackerContext();
            var role = db.Roles.FromCacheFirstOrDefault();
            role.Should().NotBeNull();

            var role2 = db.Roles.FromCacheFirstOrDefault();
            role2.Should().NotBeNull();
        }
開發者ID:jwaala,項目名稱:EntityFramework.Extended,代碼行數:9,代碼來源:CacheDbContext.cs

示例11: DeleteWithExpressionContainingNullParameter

        public void DeleteWithExpressionContainingNullParameter()
        {
            // This test verifies that the delete is processed correctly when the where expression uses a parameter with a null parameter
            var db = new TrackerContext();
            string emailDomain = "@test.com";
            string optionalComparisonString = null;

            int count = db.Users
                .Delete(u => u.EmailAddress.EndsWith(emailDomain) && (string.IsNullOrEmpty(optionalComparisonString) || u.AvatarType == optionalComparisonString));
        }
開發者ID:reconcilor,項目名稱:EntityFramework.Extended,代碼行數:10,代碼來源:BatchDbContext.cs

示例12: UpdateJoin

        public void UpdateJoin()
        {
            var db = new TrackerContext();
            string emailDomain = "@test.com";
            string space = " ";

            int count = db.Users.Update(
                u => u.EmailAddress.EndsWith(emailDomain),
                u => new User { LastName = u.FirstName + space + u.LastName });
        }
開發者ID:dioptre,項目名稱:nkd,代碼行數:10,代碼來源:BatchDbContext.cs

示例13: UpdateAppend

        public void UpdateAppend()
        {
            var db = new TrackerContext();

            string emailDomain = "@test.com";
            string newComment = " New Comment";

            int count = db.Users
                .Where(u => u.EmailAddress.EndsWith(emailDomain))
                .Update(u => new User { LastName = u.LastName + newComment });
        }
開發者ID:ArthurYiL,項目名稱:EntityFramework.Extended,代碼行數:11,代碼來源:BatchDbContext.cs

示例14: DeleteWhere

        public void DeleteWhere()
        {
            var db = new TrackerContext();
            string emailDomain = "@test.com";

            //var user = db.Users.Select(u => new User { FirstName = u.FirstName, LastName = u.LastName });

            int count = db.Users
                .Where(u => u.EmailAddress.EndsWith(emailDomain))
                .Delete();
        }
開發者ID:dioptre,項目名稱:nkd,代碼行數:11,代碼來源:BatchDbContext.cs

示例15: UpdateWithExpressionContainingNullParameter

        public void UpdateWithExpressionContainingNullParameter()
        {
            // This test verifies that the update is interpreted correctly when the where expression uses a parameter with a null parameter
            var db = new TrackerContext();
            string emailDomain = "@test.com";
            string optionalComparisonString = null;

            int count = db.Users.Update(
                u => u.EmailAddress.EndsWith(emailDomain) && (string.IsNullOrEmpty(optionalComparisonString) || u.AvatarType == optionalComparisonString),
                u => new User { IsApproved = false, LastActivityDate = DateTime.Now });
        }
開發者ID:reconcilor,項目名稱:EntityFramework.Extended,代碼行數:11,代碼來源:BatchDbContext.cs


注:本文中的Tracker.SqlServer.CodeFirst.TrackerContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。