csharp [03] Dapper Select类型#dapper

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp [03] Dapper Select类型#dapper相关的知识,希望对你有一定的参考价值。

/// Dapper Select with type
/// https://github.com/StackExchange/Dapper
public class SimpProduct {
    public int ProductID { get; set; }
    public string ProductName { get; set; }
}

using (var conn = new SqlConnection (connStr)) {
    //1) Return specifical type
    //2) Array of Int => WHERE col in (@arg1,@arg2,@arg3)
    var list = conn.Query<SimpProduct> (
        "SELECT * FROM Products WHERE CategoryID IN @id",
        new { id = new int[] { 1, 4 } });

    foreach (var item in list) {
        $"{item.ProductID} {item.ProductName}".Dump();
    }
}

以上是关于csharp [03] Dapper Select类型#dapper的主要内容,如果未能解决你的问题,请参考以下文章

csharp Dapper Call StoredProcedure #dapper

csharp Dapper Insert #dapper

csharp: mappings using Dapper-Extensions+Dapper.net.

csharp Dapper DapperExtension使支持Oracle

csharp Dapper DapperExtension使支持Oracle

csharp Dapper.Rainbow.cs