문제

I'm trying to run a custom method in subsonic query. Here is my query:

Page = Pages.SingleOrDefault(o=>Misc.MakeURL(o.Title) == URL);

and I'm getting this error:

The method 'MakeURL' is not supported

I'm using Subsonic 3. Any ideas would be great, thanks.

도움이 되었습니까?

해결책

This is simply not possible,

subsonic translates your expression to SQL, so

Pages.SingleOrDefault(o => o.Title == "title");

will propably generate a similar query like this

SELECT * FROM pages WHERE title = 'title' LIMIT 1

and you are expecting subsonic to convert your MakeUrl(...) method into SQL. What do you expect?

SELECT * FROM pages WHERE MAKEURL(title) = 'title' LIMIT 1

However, you can either just query the title or call ToList() on your pages, but that will pull all records from the database.

Page = Pages.ToList().SingleOrDefault(o=>Misc.MakeURL(o.Title) == URL);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top