非常抱歉我提出一个基础问题,但是我找不到这个错误的原因。
我正在使用Entity Framework执行存储过程,并传入了四个参数,然而SQL数据库似乎拒绝它们。有人能指点我正确的方向吗?
我的代码:
ObjectResult<SearchDirectoryItem> resultList = container.ExecuteStoreQuery<SearchDirectoryItem>("SearchDirectoryEntries",
new SqlParameter("@DirectoryId", search.DirectoryId),
new SqlParameter("@Latitude", point.Latitude),
new SqlParameter("@Longitude", point.Longitude),
new SqlParameter("@Range", search.RangeMiles));
产生错误的原因是:
过程或函数“SearchDirectoryEntries”期望提供参数“@DirectoryId”,但未提供。
生成的SQL语句为:
exec sp_executesql N'SearchDirectoryEntries',N'@DirectoryId int,@Latitude decimal(7,5),@Longitude decimal(6,5),@Range int',@DirectoryId=3,@Latitude=53.36993,@Longitude=-2.37013,@Range=10
存储过程是:
ALTER PROCEDURE [dbo].[SearchDirectoryEntries]
@DirectoryId int,
@Latitude decimal(18, 6),
@Longitude decimal(18, 6),
@Range int
非常感谢。
search.DirectoryId
是一个int
吗? - ChrisF