Using Dapper QueryMultiple in Oracle

前端 未结 3 1273
無奈伤痛
無奈伤痛 2021-02-01 22:23

I´m trying to use dapper with Oracle (ODP.NET) and I would like to use the \"QueryMultiple\" functionality.

Passing this string to the QueryMultiple method:



        
3条回答
  •  庸人自扰
    2021-02-01 22:55

    I suspect this is two or three separate things:

    1. Your first query should not have a semi-colon
    2. There is no new-line character between the queries
    3. The usage notes imply that the bind character is @ not : (no idea if this depends on the RDBMS being used).

    If you look at the Dapper Google Code page the example given for QueryMultiple() is:

    var sql = 
    @"
    select * from Customers where CustomerId = @id
    select * from Orders where CustomerId = @id
    select * from Returns where CustomerId = @id";
    
    using (var multi = connection.QueryMultiple(sql, new {id=selectedId}))
    {
       var customer = multi.Read().Single();
       var orders = multi.Read().ToList();
       var returns = multi.Read().ToList();
       ...
    } 
    

    Remove the semi-colon; add a new line and if you still have issues change the bind character.

提交回复
热议问题