本文整理汇总了C#中SimpleModel.SimpleModelContext类的典型用法代码示例。如果您正苦于以下问题:C# SimpleModelContext类的具体用法?C# SimpleModelContext怎么用?C# SimpleModelContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SimpleModelContext类属于SimpleModel命名空间,在下文中一共展示了SimpleModelContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: DbSet_FindAsync_does_not_deadlock
public void DbSet_FindAsync_does_not_deadlock()
{
using (var context = new SimpleModelContext())
{
RunDeadlockTest(() => context.Products.FindAsync(0));
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:DeadlockTests.cs
示例2: DbQuery_ToListAsync_does_not_deadlock
public void DbQuery_ToListAsync_does_not_deadlock()
{
using (var context = new SimpleModelContext())
{
RunDeadlockTest(context.Products.ToListAsync);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:DeadlockTests.cs
示例3: Database_ExecuteSqlCommandAsync_does_not_deadlock
public void Database_ExecuteSqlCommandAsync_does_not_deadlock()
{
using (var context = new SimpleModelContext())
{
RunDeadlockTest(() => context.Database.ExecuteSqlCommandAsync("select Id from Products"));
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:7,代码来源:DeadlockTests.cs
示例4: Explicit_rollback_can_be_used_to_rollback_a_transaction
public void Explicit_rollback_can_be_used_to_rollback_a_transaction()
{
EnsureDatabaseInitialized(() => new SimpleModelContext());
using (var tx = new TransactionScope())
{
using (var context = new SimpleModelContext())
{
var product = new Product
{
Name = "BestTea"
};
context.Products.Add(product);
context.SaveChanges();
Assert.Equal(1, GetTransactionCount(context.Database.Connection));
Assert.True(context.Products.Where(p => p.Name == "BestTea").AsNoTracking().Any());
// Rollback System Transaction
tx.Dispose();
Assert.False(context.Products.Where(p => p.Name == "BestTea").AsNoTracking().Any());
}
}
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:25,代码来源:TransactionTests.cs
示例5: DatabaseLogger_can_append_to_a_file
public void DatabaseLogger_can_append_to_a_file()
{
using (var context = new SimpleModelContext())
{
var output = CaptureFileOutput(
f =>
{
using (var logger = new DatabaseLogger(f, append: false))
{
logger.StartLogging();
context.Categories.ToArray();
}
using (var logger = new DatabaseLogger(f, append: true))
{
logger.StartLogging();
context.Products.ToArray();
}
});
Assert.Contains("FROM [dbo].[Categories]", output);
Assert.Contains("FROM [dbo].[Products]", output);
}
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:26,代码来源:DatabaseLoggerTests.cs
示例6: Logging_can_be_started_and_stopped
public void Logging_can_be_started_and_stopped()
{
using (var context = new SimpleModelContext())
{
var output = CaptureConsoleOutput(
() =>
{
using (var logger = new DatabaseLogger())
{
context.Products.ToArray();
logger.StartLogging();
logger.StopLogging();
context.Products.ToArray();
logger.StartLogging();
context.Categories.ToArray();
logger.StopLogging();
context.Products.ToArray();
}
});
var foundIndex = output.IndexOf("FROM [dbo].[Categories]");
Assert.True(foundIndex > 0);
foundIndex = output.IndexOf("FROM [dbo].[Categories]", foundIndex + 1);
Assert.Equal(-1, foundIndex);
Assert.DoesNotContain("FROM [dbo].[Products]", output);
}
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:34,代码来源:DatabaseLoggerTests.cs
示例7: Expression_from_static_method_with_variable
public void Expression_from_static_method_with_variable()
{
using (var context = new SimpleModelContext())
{
var products = context.Products.Where(StaticExpressions.MethodWithVariable());
Assert.DoesNotThrow(() => products.ToList());
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:ExpressionTests.cs
示例8: Expression_from_static_delegate_with_parameter
public void Expression_from_static_delegate_with_parameter()
{
using (var context = new SimpleModelContext())
{
var products = context.Products.Where(StaticExpressions.DelegateWithParameter(1));
Assert.DoesNotThrow(() => products.ToList());
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:ExpressionTests.cs
示例9: SqlQuery_ToListAsync_does_not_deadlock
public void SqlQuery_ToListAsync_does_not_deadlock()
{
using (var context = new SimpleModelContext())
{
var query = context.Database.SqlQuery<int>("select Id from Products");
RunDeadlockTest(query.ToListAsync);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:DeadlockTests.cs
示例10: Expression_from_static_property
public void Expression_from_static_property()
{
using (var context = new SimpleModelContext())
{
var products = context.Products.Where(StaticExpressions.Property);
Assert.DoesNotThrow(() => products.ToList());
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:9,代码来源:ExpressionTests.cs
示例11: Sets_are_initialized_using_name_constructor_on_DbContext
public void Sets_are_initialized_using_name_constructor_on_DbContext()
{
using (var context = new SimpleModelContext(DefaultDbName<SimpleModelContext>()))
{
Assert.NotNull(context.Products);
Assert.NotNull(context.Categories);
context.Assert<Product>().IsInModel();
context.Assert<Category>().IsInModel();
}
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:10,代码来源:DbContextTests.cs
示例12: DbContext_SaveChangesAsync_does_not_deadlock
public void DbContext_SaveChangesAsync_does_not_deadlock()
{
using (var context = new SimpleModelContext())
{
using (context.Database.BeginTransaction())
{
context.Products.Add(new Product());
RunDeadlockTest(context.SaveChangesAsync);
}
}
}
开发者ID:jesusico83,项目名称:Telerik,代码行数:11,代码来源:DeadlockTests.cs
示例13: Joining_to_named_type_projection_typed_as_DbQuery_is_handled_correctly
[Fact] // CodePlex 1751
public void Joining_to_named_type_projection_typed_as_DbQuery_is_handled_correctly()
{
using (var context = new SimpleModelContext())
{
var products = (DbQuery<MeIzNamed>)context.Products.Select(p => new MeIzNamed { Id = p.Id });
var query = context.Categories.Select(c => c.Products.Join(products, o => o.Id, i => i.Id, (o, i) => new { o, i }));
Assert.Equal(4, query.ToList().Count);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:ProjectionTests.cs
示例14: Expression_from_variable
public void Expression_from_variable()
{
Expression<Func<Product, bool>> testExpression = p => p.Id == 1;
using (var context = new SimpleModelContext())
{
var products = context.Products.Where(testExpression);
Assert.DoesNotThrow(() => products.ToList());
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:11,代码来源:ExpressionTests.cs
示例15: Large_union_all_should_not_give_query_nested_too_deeply
public void Large_union_all_should_not_give_query_nested_too_deeply()
{
var query = "{" + string.Join(", ", Enumerable.Range(1, 100)) + "}";
using (var db = new SimpleModelContext(SimpleCeConnection<SimpleModelContext>()))
{
using (var reader = QueryTestHelpers.EntityCommandSetup(db, query))
{
VerifyAgainstBaselineResults(reader, Enumerable.Range(1, 100));
}
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:SqlGeneratorTests.cs
示例16: Initialization_hooks_are_run_once_on_EF_initialization_in_the_app_domain
public void Initialization_hooks_are_run_once_on_EF_initialization_in_the_app_domain()
{
// Make sure that EF has been used if this happens to be the first test run
using (var context = new SimpleModelContext())
{
context.Database.Initialize(force: false);
}
Assert.Equal(
new[] { "Hook1()", "Hook1(2013, 'December 31')", "Hook2()", "Hook2('January 1', 2014)", "Hook2()", "Hook1(4102, '1 yraunaJ')", "Hook1()" },
TestLoadedInterceptor.HooksRun.ToArray().Reverse());
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:DbConfigurationTests.cs
示例17: DbEntityEntry_Member_works_for_collections_under_partial_trust
public void DbEntityEntry_Member_works_for_collections_under_partial_trust()
{
using (var context = new SimpleModelContext())
{
var category = context.Categories.First();
var collection = context.Entry(category).Member<ICollection<Product>>("Products");
Assert.NotNull(collection);
Assert.IsType<DbCollectionEntry<Category, Product>>(collection);
}
}
开发者ID:christiandpena,项目名称:entityframework,代码行数:12,代码来源:PartialTrustTests.cs
示例18: DbEntityEntry_ReloadAsync_does_not_deadlock
public void DbEntityEntry_ReloadAsync_does_not_deadlock()
{
using (var context = new SimpleModelContext())
{
RunDeadlockTest(
async () =>
{
await context.Products.LoadAsync().ConfigureAwait(false);
await context.ChangeTracker.Entries().First().ReloadAsync().ConfigureAwait(false);
});
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:12,代码来源:DeadlockTests.cs
示例19: Joining_to_anonymous_type_projection_is_handled_correctly
[Fact] // CodePlex 1751
public void Joining_to_anonymous_type_projection_is_handled_correctly()
{
using (var context = new SimpleModelContext())
{
var products = context.Products.Select(p => new { p.Id });
var query = context.Categories.Select(
c => c.Products
.Join(products, o => o.Id, i => i.Id, (o, i) => new { o, i }));
Assert.Equal(4, query.ToList().Count);
}
}
开发者ID:Cireson,项目名称:EntityFramework6,代码行数:14,代码来源:ProjectionTests.cs
示例20: Sets_are_initialized_using_existing_connection_constructor_on_DbContext
public void Sets_are_initialized_using_existing_connection_constructor_on_DbContext()
{
using (var connection = SimpleConnection<SimpleModelContext>())
{
using (var context = new SimpleModelContext(connection))
{
Assert.NotNull(context.Products);
Assert.NotNull(context.Categories);
context.Assert<Product>().IsInModel();
context.Assert<Category>().IsInModel();
}
}
}
开发者ID:jimmy00784,项目名称:entityframework,代码行数:13,代码来源:DbContextTests.cs
注:本文中的SimpleModel.SimpleModelContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论