本文整理汇总了C#中TestDataConnection类的典型用法代码示例。如果您正苦于以下问题:C# TestDataConnection类的具体用法?C# TestDataConnection怎么用?C# TestDataConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TestDataConnection类属于命名空间,在下文中一共展示了TestDataConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AliasTest1
public void AliasTest1()
{
using (var db = new TestDataConnection())
{
var count = db.GetTable<TestParent>().Count(t => t.ID > 0);
}
}
示例2: Test
public void Test()
{
using (var db = new TestDataConnection())
{
var q = (
from t1 in db.GetTable<Table1>()
where t1.Field3 != null
select new
{
t1.Ref1.Ref4.Field6, t1.Ref3.Field4,
Field1 = t1.Ref2.Ref5.Field8 ?? string.Empty
}
).Distinct();
var sql1 = q.ToString();
var q2 =
from t3 in q
group t3 by new { t3.Field6, t3.Field4 }
into g
where g.Count() > 1
select new { g.Key.Field6, EngineeringCircuitNumber = g.Key.Field4, Count = g.Count() };
var sql2 = q2.ToString();
var idx = sql2.IndexOf("DISTINCT");
Assert.That(idx, Is.GreaterThanOrEqualTo(0));
idx = sql2.IndexOf("Field8", idx);
Assert.That(idx, Is.GreaterThanOrEqualTo(0));
}
}
示例3: CompiledUpdate
public void CompiledUpdate()
{
using (var ctx = new TestDataConnection())
{
_updateQuery(ctx, 12345, "54321");
}
}
示例4: MergeWithDeletePredicate2
public void MergeWithDeletePredicate2(string context)
{
using (var db = new TestDataConnection(context))
{
db.Merge(db.Types2, t => t.ID > 5);
}
}
示例5: Test
public void Test()
{
using (var db = new TestDataConnection())
{
/*
var query =
from t3 in db.Parent
//let t1 = t3.Children.SelectMany(x => x.GrandChildren)
//let t2 = t3.Table2s.SelectMany(x => x.Table1s)
select new
{
//c2 = t1.Count(),
c1 = t3.Children.SelectMany(x => x.GrandChildren),
};
*/
var query =
from t3 in db.GetTable<Table3>()
let t1 = t3.Children.SelectMany(x => x.GrandChildren)
//let t2 = t3.Children.SelectMany(x => x.GrandChildren)
select new
{
c2 = t1.Count(),
c1 = t3.Children.SelectMany(x => x.GrandChildren).Count(),
};
query.FirstOrDefault(p => p.c2 > 1);
query.FirstOrDefault();
}
}
示例6: MergeWithEmptySource
public void MergeWithEmptySource(string context)
{
using (var db = new TestDataConnection(context))
{
db.Merge(new Person[] {});
}
}
示例7: ContainsJoin1
public void ContainsJoin1(string context)
{
using (var db = new TestDataConnection(context))
{
db.Child. Delete(c => c.ParentID >= 1000);
db.Parent.Delete(c => c.ParentID >= 1000);
try
{
var id = 1000;
db.Insert(new Parent { ParentID = id });
for (var i = 0; i < 3; i++)
db.Insert(new Child { ParentID = id, ChildID = 1000 + i });
var sql1 = ContainsJoin1Impl(db, new [] { 1000, 1001 });
var sql2 = ContainsJoin1Impl(db, new [] { 1002 });
Assert.That(sql1, Is.Not.EqualTo(sql2));
}
finally
{
db.Child. Delete(c => c.ParentID >= 1000);
db.Parent.Delete(c => c.ParentID >= 1000);
}
}
}
示例8: Merge
public void Merge(string context)
{
using (var db = new TestDataConnection(context))
{
db.Merge(db.Types2);
}
}
示例9: CompiledFunc2
public void CompiledFunc2([IncludeDataContexts(ProviderName.SqlServer2008)] string context)
{
using (var db = new TestDataConnection(context))
{
var q = _f2(db, 1);
q.ToList();
}
}
示例10: MergeWithDeletePredicate3
public void MergeWithDeletePredicate3(string context)
{
using (var db = new TestDataConnection(context))
{
var patient = db.Patient.First();
db.Merge(db.Person, t => t.Patient == patient);
}
}
示例11: CompiledFunc2
public void CompiledFunc2(string context)
{
using (var db = new TestDataConnection(context))
{
var q = _f2(db, 1);
q.ToList();
}
}
示例12: TestExecute2
public void TestExecute2(string context)
{
using (var conn = new TestDataConnection(context))
{
var sql = conn.Person.Where(p => p.ID == 1).Select(p => p.Name).Take(1).ToString().Replace("-- Access", "");
var res = conn.SetCommand(sql).ExecuteAsync<string>().Result;
Assert.That(res, Is.EqualTo("John"));
}
}
示例13: SubQueryCount
public void SubQueryCount(string context)
{
using (var db = new TestDataConnection(context))
{
AreEqual(
from p in Parent
select Parent.Where(t => t.ParentID == p.ParentID).Count()
,
from p in db.Parent
select Sql.AsSql(db.GetParentByID(p.ParentID).Count()));
}
}
示例14: AliasTest2
public void AliasTest2()
{
using (var db = new TestDataConnection())
{
db.GetTable<TestParent>()
.Where(t => t.ID < 0 && t.ID > 0)
.Update(t => new TestParent
{
ID = t.ID - 1
});
}
}
示例15: GeneratePredicate
public void GeneratePredicate()
{
Expression<Func<Person,bool>> a = x => x.FirstName == "John";
Expression<Func<Person,bool>> b = x => x.LastName == "Pupkin";
var bBody = b.GetBody(a.Parameters[0]);
var predicate = Expression.Lambda<Func<Person,bool>>(Expression.AndAlso(a.Body, bBody), a.Parameters[0]);
using (var db = new TestDataConnection())
{
var q = db.Person.Where(predicate);
var p = q.First();
}
}