Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 参数的OrmLite传递元组_C#_Sql Server_Tuples_<img Src="//i.stack.imgur.com/WM7S8.png" Height="16" Width="18" Alt="" Class="sponsor Tag Img">ormlite Servicestack - Fatal编程技术网 ormlite-servicestack,C#,Sql Server,Tuples,ormlite Servicestack" /> ormlite-servicestack,C#,Sql Server,Tuples,ormlite Servicestack" />

C# 参数的OrmLite传递元组

C# 参数的OrmLite传递元组,c#,sql-server,tuples,ormlite-servicestack,C#,Sql Server,Tuples,ormlite Servicestack,我想在ServiceStack或MLite查询中将具有两个属性的对象列表作为参数传递,但运行时出现错误“Mgh.Application.querys.GetDataStepThreeQuery+配置类型的成员不能用作参数值” 参数类: public class Configuration { public int RoomTypeId { get; set; } public int Adults { get; set; } } 查询: sele

我想在ServiceStack或MLite查询中将具有两个属性的对象列表作为参数传递,但运行时出现错误“Mgh.Application.querys.GetDataStepThreeQuery+配置类型的成员不能用作参数值”

参数类:

public class Configuration
    {
        public int RoomTypeId { get; set; }
        public int Adults { get; set; }
    }
查询:

select * from (values @Configurations) as V(InternalNameRoomId, MaximumPersons)
where r.InternalNameRoomId = V.InternalNameRoomId and
      r.MaximumPersons = V.MaximumPersons
通过参数:

var rooms = _db.Query<Room>(sqlRooms, new
    {
       request.From,
       request.To,
       request.EstablishmentId,
       Configurations = request.SelectedConfigurations.ToArray()
    });
var-rooms=\u db.Query(sqlRooms,新建)
{
请求,从,
请求,,
request.restitutionid,
Configurations=request.SelectedConfigurations.ToArray()
});

您尝试执行的SQL无效,RDBMS没有元组参数的概念,我不知道您尝试执行的SQL功能是从您的示例尝试执行的SQL解构元组中选择的

从对数据库运行有效SQL开始,然后可以在OrmLite中使用它,但需要将元组拆分为单独的db参数,例如:

new { item1 = Tuple.Item1, item2 = Tuple.Item2 }

另外,
db.Query
在OrmLite中使用了Dapper的嵌入式版本,OrmLite中的等效API是
db.SqlList
db.Select
,但您的SQL在这两种情况下都不起作用。

当然,SQL是有效的,我已经从这个论坛@FedericoFiaSare中删除了它,因为它对db参数不起作用,也就是说,您不能在SQL中破坏ADO.NET DB元组参数,也不能有元组DB参数。