使用 Subsonic 3 的存储过程出现 ExecuteTypedList 错误
在下面的代码块中,我尝试从 Asp.net 执行存储过程。
StoredProcedure sp = new StoredProcedure("GetIDsWithinRadius");
sp.Command.AddParameter("ZipCode", 03461);
sp.Command.AddParameter("GivenMileRadius", 4);
List<DbData.User> users = sp.ExecuteTypedList<DbData.User>();
尝试将返回数据加载到类型化列表中的最后一行代码在运行时会产生以下错误。有什么想法我做错了吗?
Server Error in '/' Application.
Implicit conversion from data type sql_variant to char is not allowed.
Use the CONVERT function to run this query.
In the code block below I am attempting to execute a Stored Procedure from Asp.net.
StoredProcedure sp = new StoredProcedure("GetIDsWithinRadius");
sp.Command.AddParameter("ZipCode", 03461);
sp.Command.AddParameter("GivenMileRadius", 4);
List<DbData.User> users = sp.ExecuteTypedList<DbData.User>();
The last line of code that tries to load the return data into a typed list produces the following error at runtime. Any ideas what I am doing wrong?
Server Error in '/' Application.
Implicit conversion from data type sql_variant to char is not allowed.
Use the CONVERT function to run this query.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您为 DbData.User 生成的代码对于存储过程返回的
sql_variant
字段可能具有错误的数据类型。最有可能的是,
sql_variant
数据类型在您的 SubSonic 版本中映射不正确(或未显式映射)。在适用于您的版本的源代码中,您可以查看 GetDbType 方法。Your generated code for DbData.User probably has the wrong data type for the
sql_variant
field being returned by your stored procedure.Most likely, the
sql_variant
data type is mapped incorrectly (or not mapped explicitly) in your version of SubSonic. In the source that applies to your version, you could look to see whatsql_variant
is mapped to in the GetDbType method.