The compiled query will return a set of values, so in order to get it working, try changing the return type to IEnumerable<KeyValuePair<string, int>>
- you are returning a set of values, not just one single value. You might then want to change the function name for the compiled query to GetJourneysByUrl
.
Then to get a single value from the result set (implied by the function name of GetJourneyByUrl
) then you should add a function to return the first item returned by the compiled query.
public static KeyValuePair<string, int> GetJourneyByUrl(DataContext dc, string urlSlug) {
return GetJourneysByUrl(dc, urlSlug).First();
}
You can also set this up as a Func
, as shown on this msdn page related to compiled queries.