This is a migrated thread and some comments may be shown as answers.

Dynamic linq using a method of an object

1 Answer 100 Views
Data Access Free Edition
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
LordRevan007
Top achievements
Rank 1
LordRevan007 asked on 01 Jun 2012, 08:48 AM
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.

1 Answer, 1 is accepted

Sort by
0
Thomas
Telerik team
answered on 04 Jun 2012, 07:02 PM
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.


Greetings,
Thomas
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!
Tags
Data Access Free Edition
Asked by
LordRevan007
Top achievements
Rank 1
Answers by
Thomas
Telerik team
Share this question
or