I have written a LINQ query with or condition in it, but its not working, it seem I am doing something wrong.
I am passing a string value and on it, I want to get my result.
var userDetails = context.tbl_members.Where
(
d => d.Mobile == value
||
d.MemberId == Int32.Parse(value)
).SingleOrDefault();
its not working if someone put a mobile no, but if work with memberID
if I split the query keep only mobile no its running fine.
var userDetails = context.tbl_members.Where(d => d.Mobile == value ).SingleOrDefault();
Please check what I did wrong with or condition
Regards
Moksha
It looks like you are using Linq to Entities or Linq to Sql.
Int32.Parse()is not supported in that context – just do the number conversion before your query: