Hi, I am having problems trying to implement CustomLinq rewriter to calculate the age of a person. I am getting an over that the method GetAge is not valid. I am not sure that I am implementing it properly. Thank you, Richard public class Person : BaseEntity { [Field(Length = 128)] public string FirstName { get; set; }
}
|
Hello Richard, since all of your code needs to be translate somehow to SQL you need to provide translation for |
Denis, GetAge is my own custom function... It's says that the function is not supported in my LINQ query. Everything compiles find so the function exists.. Thank you, Here is the error message Xtensive.Orm.QueryTranslationException was unhandled
HResult=-2146233088
Message=Unable to translate 'Query.All().Where(v => (v.Visitor.Age_in_Years <= 18)).GroupBy(i => i.Visitor.FullName).Select(g => new @<race, male,="" female="">(
g.Key,
g.Count(s => (((Int32)s.Visitor.Sex) == 77)),
g.Count(s => (((Int32)s.Visitor.Sex) == 70))
))' expression. See inner exception for details.
Source=Xtensive.Orm
StackTrace:
at Xtensive.Orm.Linq.QueryProvider.TranslateTResult
at Xtensive.Orm.Linq.QueryProvider.ExecuteTResult
at Xtensive.Orm.Linq.Queryable Sorry, I did understand your reply before. So I guess there is no other way other than sql user defined function? Richard Richard, you need to write translation for You can use many How would I go about writing a transalation.. Do You mean I have to write another custom compiler container function for GetAge? Yes, you're right. LINQ translator will apply all your custom compilers recursively. After all transformations performed you should be using only supported members, otherwise an exception will be thrown. |
Hello X-tensive,
Have you been able to look for an answer to my issue. I am working on a project and really need this resolved.
Thank you,
Richard