Dynamic linq using a method of an object

2 posts, 0 answers
  1. LordRevan007
    LordRevan007 avatar
    20 posts
    Member since:
    May 2011

    Posted 01 Jun 2012 Link to this post

    Hello, the problem for me sounds like this. I have a class A, that is generated by the diagram, along with that I created another method M that belogns to A in a separte file that is not affected by the code generation as Telerik recommends, which returns a string. Now, I am trying to create a dynamic linq query that has the string query.Context.GetAll<A>.Where("M().contains("\"x"\").  I've include the type A in the base types of dynamic linq, but it throws me an exception, that M method that does'not exist, or something like this.

    Is this possible with OA and the dlinq library, or should I reconsider the strategy. I know there are some problems with methods defined for object in the model when used in linq query, but if introduce them as range variables, the problem are no more.

    Thanks in advance.
  2. Thomas
    Thomas avatar
    588 posts

    Posted 04 Jun 2012 Link to this post

    From looking at the code you should be able to call static methods by Name.Method once you have added them to the predefined type list.
    What you cannot do (even when you alter the Dynamic.cs code) is to push methods to the server because OpenAccess does not know what to do with it. You would need to mark the method with [SqlFunction] to achieve that.
    My advice is not to alter the Dynamic.cs code to much and rather search for a non-dynamic approach.

    the Telerik team
    Follow @OpenAccessORM Twitter channel to be the first one to get the latest updates on new releases, tips and tricks and sneak peeks at our product labs!
  3. DevCraft banner
Back to Top