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

DataServiceKey attribute and ADO.NET dataservice

3 Answers 130 Views
Design Time (Visual Designer & Tools)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Henk
Top achievements
Rank 1
Henk asked on 02 Nov 2009, 01:20 PM
Hello,

I tried to make an ADO.NET dataservice using the OA WCF wizard.
I had a problem using the ADO.NET dataservice because there are no DataServiceKey attributes added to the OA classes.
Is it possible to automatically add a DataServiceKey attribute to each class based on the primary key fields of the table?

3 Answers, 1 is accepted

Sort by
0
Accepted
Alexander
Telerik team
answered on 03 Nov 2009, 12:57 PM
Hi Henk Boen,

You can edit the template that OpenAccess uses for class generation. The directory where the templates reside is <OpenAccess install path>\sdk\IDEIntegrations\templates\PCClassGeneration\cs\templates\classgen\class. If you are using partial classes open the partialdesignerdefault.vm file, otherwise - the default.vm file. In both cases, the file contains a line similar to this:
...
public partial class $className
...
What you should do is to add the DataServiceKey attribute above as follows:
...
[DataServiceKey#if($singleField)("$(pkField)")#end]
public partial class $className
...
Note that changing the templates reflects all newly generated classes. If you do not need the DataServiceKey attribute anymore, please revert the changes.

Greetings,
Alexander
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Sam
Top achievements
Rank 1
answered on 07 Nov 2009, 08:38 PM
hi Alexander,
i faced same issue and i have one issue with your solution 
pkField return the field Name while i need the pk Property Name 
how can i return it instead on the Field name? 

best regards,
Sam

0
PetarP
Telerik team
answered on 11 Nov 2009, 03:54 PM
Hello Sam,

We are aware of this problem. The functionality is implemented and it will be part of our next internal build. With the next build you will be able to modify the template as follows:
[DataServiceKey#if($multipleField)(new string[]{"$(pkProperties)"})#end#if($singleField)("$(pkProperty)")#end]
As you can see above, the template will be able to generate the correct DataServiceKey for both single identity and multiple identity.

Sincerely yours,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Design Time (Visual Designer & Tools)
Asked by
Henk
Top achievements
Rank 1
Answers by
Alexander
Telerik team
Sam
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or