我是从C#应用程序中的Dapper开始的(我目前在大多数地方使用实体)并且我遇到了简单查询的问题。
我一直回来"必须声明标量变量' @ReportId'"但我宣布了!
In [6]: exploded
Out[6]:
ID name price rank
0 13423 A $1.00 1
1 13423 B $4.00 2
2 13423 C $3.99 3
3 13423 D $2.00 4
4 13423 E $2.50 5
5 294847 AA $1.99 1
6 294847 BB $6.99 2
7 322844 Z $0.99 1
8 322844 Y $10.00 2
9 322844 X $1.99 3
9 429847 NaN NaN NaN
这是我的班级:
db.Execute(@"INSERT INTO cdr_Requests (ReportId, ReportName, StartTime, EndTime, Status, ReportUrl, CreatedAt, UpdatedAt, Timezone, CdrReportRead) VALUES (@ReportId, @ReportName, @StartTime, @EndTime, @Status, @ReportUrl, @CreatedAt, @UpdatedAt, @Timezone, @CdrReportRead)", new { data.id, data.report_name, data.start_time, data.end_time, data.status, data.report_url, data.created_at, data.updated_at, data.timezone, data.cdrreportread });
我在弄清楚发生了什么事时遇到了麻烦!
答案 0 :(得分:3)
好吧显然我有一个完整的脑屁并且看着错误的线路。我改为这个并且有效:
db.Execute(@"INSERT INTO cdr_Requests (ReportId, ReportName, StartTime, EndTime, Status, ReportUrl, CreatedAt, UpdatedAt, Timezone, CdrReportRead)
VALUES (@ReportId, @ReportName, @StartTime, @EndTime, @Status, @ReportUrl, @CreatedAt, @UpdatedAt, @Timezone, @CdrReportRead)", new {
ReportId = data.id,
ReportName = data.report_name,
StartTime = data.start_time,
EndTime = data.end_time,
Status = data.status,
ReportUrl = data.report_url,
CreatedAt = data.created_at,
UpdatedAt = data.updated_at,
Timezone = data.timezone,
CdrReportRead = 0
});
答案 1 :(得分:0)
只要万一F#偷窥者遇到“必须声明标量变量问题”,通常是因为您在私有模块中声明了参数记录。例如
module private MyStuff =
type Params = { MyParam : int }
您只需要移动类型或取消对该模块的私有化即可。