本文整理汇总了C#中Data.Linq.TestDbManager类的典型用法代码示例。如果您正苦于以下问题:C# TestDbManager类的具体用法?C# TestDbManager怎么用?C# TestDbManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestDbManager类属于Data.Linq命名空间,在下文中一共展示了TestDbManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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]);
}
示例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);
}
}
}
示例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" });
}
}
示例4: UserInsert
public void UserInsert([IncludeDataContexts("Oracle")] string context)
{
using (var db = new TestDbManager(context))
{
db.BeginTransaction();
db.Insert(new User { Name = "user" });
}
}
示例5: UserInsertWithIdentity
public void UserInsertWithIdentity()
{
using (var db = new TestDbManager("Oracle"))
{
db.BeginTransaction();
db.InsertWithIdentity(new User { Name = "user" });
}
}
示例6: UserLinqInsertWithIdentity
public void UserLinqInsertWithIdentity()
{
using (var db = new TestDbManager("Oracle"))
{
db.BeginTransaction();
db.GetTable<User>().InsertWithIdentity(() => new User { Name = "user" });
}
}
示例7: CompiledFunc2
public void CompiledFunc2([IncludeDataContexts("Sql2008", "Sql2012")] string context)
{
using (var db = new TestDbManager(context))
{
var q = _f2(db, 1);
q.ToList();
}
}
示例8: CompiledFunc2
public void CompiledFunc2()
{
using (var db = new TestDbManager())
{
var q = _f2(db, 1);
q.ToList();
}
}
示例9: AllNames
public void AllNames()
{
using (var db = new TestDbManager("Sql2008"))
db.GetTable<ParenTable>()
.DatabaseName("BLToolkitData")
.OwnerName("dbo")
.TableName("Parent")
.ToList();
}
示例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();
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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());
}
}