本文整理汇总了C#中DbConnection.Select方法的典型用法代码示例。如果您正苦于以下问题:C# DbConnection.Select方法的具体用法?C# DbConnection.Select怎么用?C# DbConnection.Select使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbConnection
的用法示例。
在下文中一共展示了DbConnection.Select方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ShouldInsertAnObject
public async Task ShouldInsertAnObject()
{
using (var db = new DbConnection())
{
Enumerable.Range(0, 100).ToList().ForEach(_ => db.InsertAsync(new Person {Name = "Rick Bobby"}).Wait());
var people = await db.Select<Person>().SelectAsync();
people.Count().Should().Be(100);
}
}
示例2: ShouldSelectEquals
public async Task ShouldSelectEquals()
{
using (var db = new DbConnection())
{
await db.InsertAsync(new Person {Name = "Rick Bobby"});
var query = db.Select<Person>().Where(p => p.Id, Sql.Equals(1));
var people = await query.SelectAsync();
var person = await query.SelectSingleAsync();
people.Count().Should().Be(1);
person.Should().NotBe(null);
}
}
示例3: ShouldSelectLike
public async Task ShouldSelectLike()
{
using (var db = new DbConnection<Person>())
{
await db.InsertCollectionAsync(new List<Person>
{
new Person {Name = "Jonathan Swieboda"},
new Person {Name = "James Nathan Smith"}
});
var query = db.Select(p => p.Name).Where(p => p.Name, Sql.Like("%"));
var people = await query.SelectAsync();
people.Count().Should().Be(2);
}
}