Click here to Skip to main content
15,892,839 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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

{"The argument types 'Edm.Int32' and 'Edm.String' are incompatible for this operation. Near WHERE predicate, line 1, column 82."}

C#
var loc = (e.Row.Cells[1].Text);
locationID = context.PanchayatiRajLocations.Find(loc).ID;

Here locationId is Type of Int32.
Posted
Updated 9-Nov-13 1:52am
v2
Comments
♥…ЯҠ…♥ 9-Nov-13 8:05am    
Did you check e.Row.Cells[1].Text value? what you get in var loc? see it in quick watch window
Neha Mukesh 12-Nov-13 4:05am    
hi
e.row.cells[1].text returns name .That's i can't convert it into INT32
Neha Mukesh 12-Nov-13 4:05am    
hi
e.row.cells[1].text returns name .That's i can't convert it into INT32
♥…ЯҠ…♥ 12-Nov-13 5:00am    
Updated my solution as per your comments..... try it and lemme know

1 solution

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
C#
var loc = (e.Row.Cells[1].Text);

with this line
C#
var loc = Convert.ToInt32(e.Row.Cells[1].Text);
Updated solution:
Try this query and see what you get...
SQL
var locationID = from obj in context.PanchayatiRajLocations
                           where loc == "London"
                           select obj.ID;

Hope this helps you a bit.

Regards,
RK
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900