Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Mar 05, 2012 05:47 PM by Setty
Feb 29, 2012 03:02 PM|LINK
I want to compare an integer with string with EF 4.2.I tried using SqlFunctions.StringConvert but it did not retreive any result set.Please let me know how can i achieve this without modifying the data type of entity.Here is the example i tried with LinqPad:
s in Study
join ds in DMIDStudy on s.SourceStudyID equals SqlFunctions.StringConvert((double)ds.StudyID)
Here SourceStudyID is the string and StudyID is the integer.Please let me know how can i join these 2 entities.Also DMIDStudy is in different schema and Study in different schema.But they are under the same Database.
Feb 29, 2012 04:52 PM|LINK
Looks like you're trying to compare an integer to a double. Your best bet will be to convert SourceStudyID to a double.
Feb 29, 2012 04:57 PM|LINK
I tried that too. I got an error saying "Cannot convert type 'string' to 'double' " . Here is the statement i tried
s in Study
join ds in DMIDStudy on SqlFunctions.StringConvert((double)s.SourceStudyID) equals ds.StudyID
Feb 29, 2012 06:16 PM|LINK
Get rid of SqlFunctions.StringConvert
Feb 29, 2012 07:03 PM|LINK
Can you give me an example? I tried that way it gives error Cannot convert type 'string' to 'double'
Mar 01, 2012 07:18 AM|LINK
join ds in DMIDStudy on s.SourceStudyID) equals ds.StudyID.ToString()
or use Convert.ToInt32()
Mar 02, 2012 12:32 AM|LINK
You can never change from a string to double，try to use Convert……
Mar 02, 2012 01:59 PM|LINK
I tried that way,it says "The type of one of the expressions in the join clause is incorrect. Type inference failed in the call to 'Join'. "
Here is the code i tried:
from s in Study
join ds in DMIDStudy on SqlFunctions.StringConvert(Convert.ToDouble(s.StudySourceID)) equals ds.DMIDStudyID
Mar 02, 2012 11:57 PM|LINK
You've got a syntax error，it should be this following：
var result = from e in xxx
join f inn yyy on e.ZZZ equals f.AAA
So plz change to this following：
var result = from s in Study
join ds in DMIDStudy on
I don't think the bold,underlined can be a member that is compared with ds.DMIDStudyID。
Mar 05, 2012 05:47 PM|LINK
I solved that problem by creating SQL view .