本文整理汇总了C#中Tracker.SqlServer.CodeFirst.TrackerContext类的典型用法代码示例。如果您正苦于以下问题:C# TrackerContext类的具体用法?C# TrackerContext怎么用?C# TrackerContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TrackerContext类属于Tracker.SqlServer.CodeFirst命名空间,在下文中一共展示了TrackerContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: GetInheritedEntityMapAuditData
public void GetInheritedEntityMapAuditData()
{
var db = new TrackerContext();
var resolver = new MetadataMappingProvider();
var map = resolver.GetEntityMap(typeof(CodeFirst.Entities.Task), db);
//var map = db.Audits.ToObjectQuery().GetEntityMap<AuditData>();
Assert.Equal("[dbo].[Task]", map.TableName);
}
开发者ID:ArthurYiL,项目名称:EntityFramework.Extended,代码行数:11,代码来源:MappingObjectContext.cs
示例17: GetEntityMapAuditData
public void GetEntityMapAuditData()
{
var db = new TrackerContext();
var resolver = new MetadataMappingProvider();
var map = resolver.GetEntityMap(typeof(AuditData), db);
//var map = db.Audits.ToObjectQuery().GetEntityMap<AuditData>();
Assert.AreEqual("[dbo].[Audit]", map.TableName);
}
开发者ID:RobersonLuo,项目名称:EntityFramework.Extended,代码行数:11,代码来源:MappingObjectContext.cs
示例18: CreateLog
public void CreateLog()
{
var auditConfiguration = AuditConfiguration.Default;
auditConfiguration.IncludeRelationships = true;
auditConfiguration.LoadRelationships = true;
auditConfiguration.DefaultAuditable = true;
// customize the audit for Task entity
auditConfiguration.IsAuditable<Task>()
.NotAudited(t => t.TaskExtended)
.FormatWith(t => t.Status, v => FormatStatus(v));
// set name as the display member when status is a foreign key
auditConfiguration.IsAuditable<Status>()
.DisplayMember(t => t.Name);
var db = new TrackerContext();
var user1 = new User()
{
Id = 1
};
db.Users.Add(user1);
var audit = db.BeginAudit();
var user = db.Users.Find(1);
user.Comment = "Testing: " + DateTime.Now.Ticks;
var task = new Task()
{
Id = 1,
AssignedId = 1,
CreatedId = 1,
StatusId = 1,
PriorityId = 2,
Summary = "Summary: " + DateTime.Now.Ticks
};
db.Tasks.Add(task);
var task2 = db.Tasks.Find(1);
task2.PriorityId = 2;
task2.StatusId = 2;
task2.Summary = "Summary: " + DateTime.Now.Ticks;
var log = audit.CreateLog();
Assert.IsNotNull(log);
string xml = log.ToXml();
Assert.IsNotNull(xml);
}
开发者ID:fpellet,项目名称:EntityFramework.Extended,代码行数:52,代码来源:AuditTest.cs
示例19: CreateLogLoaded
public void CreateLogLoaded()
{
var auditConfiguration = AuditConfiguration.Default;
auditConfiguration.IncludeRelationships = true;
auditConfiguration.LoadRelationships = true;
auditConfiguration.DefaultAuditable = true;
// customize the audit for Task entity
//auditConfiguration.IsAuditable<Task>()
// .NotAudited(t => t.TaskExtended)
// .FormatWith(t => t.Status, v => FormatStatus(v));
// set name as the display member when status is a foreign key
auditConfiguration.IsAuditable<Status>()
.DisplayMember(t => t.Name);
var db = new TrackerContext();
var audit = db.BeginAudit();
var user = db.Users.Find(1);
user.Comment = "Testing: " + DateTime.Now.Ticks;
var newTask = new Task()
{
AssignedId = 1,
CreatedId = 1,
StatusId = 1,
PriorityId = 2,
Summary = "Summary: " + DateTime.Now.Ticks
};
db.Tasks.Add(newTask);
var p = db.Priorities.Find(2);
var updateTask = db.Tasks.Find(1);
updateTask.Priority = p;
updateTask.StatusId = 2;
updateTask.Summary = "Summary: " + DateTime.Now.Ticks;
var log = audit.CreateLog();
Assert.IsNotNull(log);
string xml = log.ToXml();
Assert.IsNotNull(xml);
foreach (var property in log.Entities.SelectMany(e => e.Properties))
{
Assert.AreNotEqual(property.Current, "{error}");
Assert.AreNotEqual(property.Original, "{error}");
}
}
开发者ID:reconcilor,项目名称:EntityFramework.Extended,代码行数:52,代码来源:AuditTest.cs
示例20: SelectByKey
public void SelectByKey()
{
var db = new TrackerContext();
var contextAdapter = db as IObjectContextAdapter;
var objectContext = contextAdapter.ObjectContext;
var sql = "SELECT VALUE U.EmailAddress FROM TrackerContext.Users AS U WHERE U.Id = 1";
var q = objectContext.CreateQuery<object>(sql);
var list = q.FirstOrDefault();
list.Should().NotBeNull();
}
开发者ID:jwaala,项目名称:EntityFramework.Extended,代码行数:15,代码来源:SqlTests.cs
注:本文中的Tracker.SqlServer.CodeFirst.TrackerContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论