本文整理汇总了C#中Data.Linq.TestDbManager类的典型用法代码示例。如果您正苦于以下问题:C# TestDbManager类的具体用法?C# TestDbManager怎么用?C# TestDbManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestDbManager类属于Data.Linq命名空间,在下文中一共展示了TestDbManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: ConcurentTest1
public void ConcurentTest1()
{
var query = CompiledQuery.Compile((ITestDataContext db, int n) => db.GetTable<Parent>().Where(p => p.ParentID == n).First().ParentID);
const int count = 100;
var threads = new Thread[count];
var results = new int [count, 2];
for (var i = 0; i < count; i++)
{
var n = i;
threads[i] = new Thread(() =>
{
using (var db = new TestDbManager("Sql2008"))
{
var id = (n % 6) + 1;
results[n,0] = id;
results[n,1] = query(db, id);
}
});
}
for (var i = 0; i < count; i++)
threads[i].Start();
for (var i = 0; i < count; i++)
threads[i].Join();
for (var i = 0; i < count; i++)
Assert.AreEqual(results[i,0], results[i,1]);
}
开发者ID:Lonli-Lokli,项目名称:bltoolkit,代码行数:33,代码来源:CompileTest.cs
示例2: Transaction
public void Transaction()
{
foreach (var provider in Providers)
{
using (var db = new TestDbManager(provider.Name))
{
var list = new[]
{
new Parent { ParentID = 1111, Value1 = 1111 },
new Parent { ParentID = 2111, Value1 = 2111 },
new Parent { ParentID = 3111, Value1 = 3111 },
new Parent { ParentID = 4111, Value1 = 4111 },
};
foreach (var parent in list)
db.Parent.Delete(p => p.ParentID == parent.ParentID);
db.BeginTransaction();
db.InsertBatch(list);
db.CommitTransaction();
foreach (var parent in list)
db.Parent.Delete(p => p.ParentID == parent.ParentID);
}
}
}
开发者ID:Gremlin2,项目名称:bltoolkit,代码行数:26,代码来源:BatchTest.cs
示例3: UserLinqInsertWithIdentity
public void UserLinqInsertWithIdentity([IncludeDataContexts("Oracle")] string context)
{
using (var db = new TestDbManager(context))
{
db.BeginTransaction();
db.GetTable<User>().InsertWithIdentity(() => new User { Name = "user" });
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:8,代码来源:TestAK107.cs
示例4: UserInsert
public void UserInsert([IncludeDataContexts("Oracle")] string context)
{
using (var db = new TestDbManager(context))
{
db.BeginTransaction();
db.Insert(new User { Name = "user" });
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:8,代码来源:TestAK107.cs
示例5: UserInsertWithIdentity
public void UserInsertWithIdentity()
{
using (var db = new TestDbManager("Oracle"))
{
db.BeginTransaction();
db.InsertWithIdentity(new User { Name = "user" });
}
}
开发者ID:starteleport,项目名称:bltoolkit,代码行数:8,代码来源:TestAK107.cs
示例6: UserLinqInsertWithIdentity
public void UserLinqInsertWithIdentity()
{
using (var db = new TestDbManager("Oracle"))
{
db.BeginTransaction();
db.GetTable<User>().InsertWithIdentity(() => new User { Name = "user" });
}
}
开发者ID:starteleport,项目名称:bltoolkit,代码行数:8,代码来源:TestAK107.cs
示例7: CompiledFunc2
public void CompiledFunc2([IncludeDataContexts("Sql2008", "Sql2012")] string context)
{
using (var db = new TestDbManager(context))
{
var q = _f2(db, 1);
q.ToList();
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:8,代码来源:TableFunctionTest.cs
示例8: CompiledFunc2
public void CompiledFunc2()
{
using (var db = new TestDbManager())
{
var q = _f2(db, 1);
q.ToList();
}
}
开发者ID:ivanoffalex,项目名称:bltoolkit,代码行数:8,代码来源:TableFunctionTest.cs
示例9: AllNames
public void AllNames()
{
using (var db = new TestDbManager("Sql2008"))
db.GetTable<ParenTable>()
.DatabaseName("BLToolkitData")
.OwnerName("dbo")
.TableName("Parent")
.ToList();
}
开发者ID:Gremlin2,项目名称:bltoolkit,代码行数:9,代码来源:ExtensionTests.cs
示例10: AllNames
public void AllNames([IncludeDataContexts("Sql2008")] string context)
{
using (var db = new TestDbManager(context))
db.GetTable<ParenTable>()
.DatabaseName("TestData")
.OwnerName("dbo")
.TableName("Parent")
.ToList();
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:9,代码来源:ExtensionTests.cs
示例11: WithTabLock
public void WithTabLock([IncludeDataContexts("Sql2008", "Sql2012")] string context)
{
using (var db = new TestDbManager(context))
{
var q =
from p in new Model.Functions(db).WithTabLock<Parent>()
select p;
q.ToList();
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:11,代码来源:TableFunctionTest.cs
示例12: Func1
public void Func1([IncludeDataContexts("Sql2008", "Sql2012")] string context)
{
using (var db = new TestDbManager(context))
{
var q =
from p in new Model.Functions(db).GetParentByID(1)
select p;
q.ToList();
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:11,代码来源:TableFunctionTest.cs
示例13: WithTabLock
public void WithTabLock()
{
using (var db = new TestDbManager())
{
var q =
from p in new Model.Functions(db).WithTabLock<Parent>()
select p;
q.ToList();
}
}
开发者ID:ivanoffalex,项目名称:bltoolkit,代码行数:11,代码来源:TableFunctionTest.cs
示例14: Func1
public void Func1()
{
using (var db = new TestDbManager())
{
var q =
from p in new Model.Functions(db).GetParentByID(1)
select p;
q.ToList();
}
}
开发者ID:ivanoffalex,项目名称:bltoolkit,代码行数:11,代码来源:TableFunctionTest.cs
示例15: Main
static void Main()
{
BLToolkit.Data.DbManager.AddDataProvider(typeof(BLToolkit.Data.DataProvider.MySqlDataProvider));
using (var db = new TestDbManager("MySql"))
{
var list = new GenericConcatQuery(db, new object[] { "A", 1 }).Query().ToList();
foreach (var i in list)
Console.WriteLine(i.ToString());
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:12,代码来源:Program.cs
示例16: Func3
public void Func3([IncludeDataContexts("Sql2008", "Sql2012")] string context)
{
using (var db = new TestDbManager(context))
{
var q =
from c in db.Child
from p in db.GetParentByID(c.ParentID)
select p;
q.ToList();
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:12,代码来源:TableFunctionTest.cs
示例17: Func3
public void Func3()
{
using (var db = new TestDbManager())
{
var q =
from c in db.Child
from p in db.GetParentByID(c.ParentID)
select p;
q.ToList();
}
}
开发者ID:ivanoffalex,项目名称:bltoolkit,代码行数:12,代码来源:TableFunctionTest.cs
示例18: SubQueryCount
public void SubQueryCount([IncludeDataContexts("Sql2008", "Sql2012")] string context)
{
using (var db = new TestDbManager(context))
{
AreEqual(
from p in Parent
select Parent.Where(t => t.ParentID == p.ParentID).Count()
,
from p in db.Parent
//select Sql.AsSql(db.Parent.Count()));
select Sql.AsSql(db.GetParentByID(p.ParentID).Count()));
}
}
开发者ID:MajidSafari,项目名称:bltoolkit,代码行数:13,代码来源:CountTest.cs
示例19: SubQueryCount
public void SubQueryCount()
{
using (var db = new TestDbManager())
{
AreEqual(
from p in Parent
select Parent.Where(t => t.ParentID == p.ParentID).Count()
,
from p in db.Parent
//select Sql.AsSql(db.Parent.Count()));
select Sql.AsSql(db.GetParentByID(p.ParentID).Count()));
}
}
开发者ID:bonza,项目名称:bltoolkit,代码行数:13,代码来源:CountTest.cs
示例20: IsDbGeneratedTest
public void IsDbGeneratedTest()
{
using (var db = new TestDbManager("Sql2008"))
{
var id = db.InsertWithIdentity(new L2SPersons
{
FirstName = "Test",
LastName = "Test",
Gender = "M"
});
db.GetTable<L2SPersons>().Delete(p => p.PersonID == ConvertTo<int>.From(id));
}
}
开发者ID:Lonli-Lokli,项目名称:bltoolkit,代码行数:14,代码来源:L2SAttributes.cs
注:本文中的Data.Linq.TestDbManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论