Dapper.NET 查询静态类型
示例
对于在编译时已知的类型,请使用带有的通用参数Query<T>。
public class Dog { public int? Age { get; set; } public Guid Id { get; set; } public string Name { get; set; } public float? Weight { get; set; } public int IgnoredProperty { get { return 1; } } } // IDBConnection db = /* ... */; var @params = new { age = 3 }; var sql = "SELECT * FROMdbo.DogsWHERE Age = @age"; IEnumerable<Dog> dogs = db.Query<Dog>(sql, @params);