请解决此错误.Argument异常被捕获 [英] Please solve this error.Argument Exception was caught
本文介绍了请解决此错误.Argument异常被捕获的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
The type of one of the primary key values did not match the type defined in the entity. See inner exception for details.
Parameter name: keyValues
{参数类型'Edm.Int32'和'Edm.String'与此操作不兼容。靠近WHERE谓词,行1,第82栏。}
{"The argument types 'Edm.Int32' and 'Edm.String' are incompatible for this operation. Near WHERE predicate, line 1, column 82."}
var loc = (e.Row.Cells[1].Text);
locationID = context.PanchayatiRajLocations.Find(loc).ID;
这里locationId是Int32的类型。
Here locationId is Type of Int32.
推荐答案
你好Neha,
您正在尝试将int与字符串进行比较导致此问题的查询我相信。
尝试先看看你在loc变量中获得的内容
否则尝试替换
Hi Neha,
You are trying to compare int with string the query that leads to this problem I believe.
Try to see what you get in loc variable first
otherwise try to replace
var loc = (e.Row.Cells[1].Text);
使用此行
with this line
var loc = Convert.ToInt32(e.Row.Cells[1].Text);
更新解决方案:
试试这个查询,看看你得到了什么...
Updated solution:
Try this query and see what you get...
var locationID = from obj in context.PanchayatiRajLocations
where loc == "London"
select obj.ID;
希望这对你有所帮助。
问候,
RK
Hope this helps you a bit.
Regards,
RK
这篇关于请解决此错误.Argument异常被捕获的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文