Generating WCF Data Services Compliant model

Posts   
 
    
Posts: 5
Joined: 19-Oct-2010
# Posted on: 19-Oct-2010 17:38:52   

Hi,

First some background information:

LLBLGen version: LLBLGen pro 3.0 (trial version) Database Targeted: Oracle 11g Template Group: Self Servicing Entities Language: C# **Core Requirement: To generate a WCF Data Services friendly LinqMetaData class for the model ** Target platform: .Net 4.0

Issues 1. I am not able to use the default generated LinqMetaData class as expected with the WCF Data Service If I take the LinqMetaData class that is generated by default in the WCF DataService it throws up errors such as below

_The server encountered an error processing the request. The exception message is 'On data context type 'LinqMetaData', there is a top IQueryable property 'AccessCode' whose element type is not an entity type. Make sure that the IQueryable property is of entity type or specify the IgnoreProperties attribute on the data context type to ignore this property.'. See server logs for more details. The exception stack trace is:

at System.Data.Services.Providers.ReflectionServiceProvider.PopulateMetadata(IDictionary2 knownTypes, IDictionary2 childTypes, IDictionary2 entitySets) at System.Data.Services.Providers.BaseServiceProvider.PopulateMetadata() at System.Data.Services.DataService1.CreateProvider() at System.Data.Services.DataService1.HandleRequest() at System.Data.Services.DataService1.ProcessRequestForMessage(Stream messageBody) at SyncInvokeProcessRequestForMessage(Object , Object[] , Object[] ) at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs) at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc) at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc& rpc) at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)_

2. I tried but was not able to get the custom template for ADO DS to work If I try to use the custom templates that are provided in a separate thread on this forum(_the custom templates target v 3.5 ADO DS so i changed the target to Framework 3.5_) then first I get an error while saving the custom Preset in the regular Program File directory (is it because i am using Windows 7?maybe). When I resolve that by saving it in a different directory than the one under Program Files the list of tasks (Run Queue) for the custom Preset comes as blank. Even if explicitly add the tasks for the ConsumeTDLTemplate or merge this new preset with an existing one the code generation does not work properly for some specific tasks (the ones that would generate the custom LinqMetaData class, i believe) and we get an error stating :

Could not find template 'SD_TemplateID'. It is not defined in the used templatebindings or is empty. It can be it's not defined for the current database (e.g. stored procedure templates for SqlServer CE)

Any pointers as to what is going wrong or what can be done differently to get the scenario to work will be appreciated. Please help ASAP as so far the team has been very impressed with the Performance of LLBLGen for the model generation and it would be a really good business case if we can use this model for our huge database (about 700-800 tables with some complex relationships) in WCF Data Service !!!

MTrinder
User
Posts: 1461
Joined: 08-Oct-2008
# Posted on: 19-Oct-2010 21:00:24   

Have you looked at the WCF example in the customer downloads section of the website...? It gives good examples of how to set this up.

Matt

Posts: 5
Joined: 19-Oct-2010
# Posted on: 19-Oct-2010 22:03:34   

Hi MTrinder,

I am looking for support for WCF Data Service (earlier known as ADO.Net Data Services) which will allow one to expose the LLBLGen generated model using the OData convention. The examples are about WCF RIA Services and regular WCF Service. There was one post that provided templates for the ertswhile ADO.Net Data Service but I am unable to get it to work (please see details in the original message). It gives the following error during code generation:

Could not find template 'SD_TemplateID'. It is not defined in the used templatebindings or is empty. It can be it's not defined for the current database (e.g. stored procedure templates for SqlServer CE)

Any ideas on what could be going wrong?

Thanks in advance

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 20-Oct-2010 05:58:01   

Hi Sajjad, Lets face one issue at a time.

Sajjad.Nasir wrote:

2. I tried but was not able to get the custom template for ADO DS to work If I try to use the custom templates that are provided in a separate thread on this forum(_the custom templates target v 3.5 ADO DS so i changed the target to Framework 3.5_) then first I get an error while saving the custom Preset in the regular Program File directory (is it because i am using Windows 7?maybe). When I resolve that by saving it in a different directory than the one under Program Files the list of tasks (Run Queue) for the custom Preset comes as blank. Even if explicitly add the tasks for the ConsumeTDLTemplate or merge this new preset with an existing one the code generation does not work properly for some specific tasks (the ones that would generate the custom LinqMetaData class, i believe) and we get an error stating :

Could not find template 'SD_TemplateID'. It is not defined in the used templatebindings or is empty. It can be it's not defined for the current database (e.g. stored procedure templates for SqlServer CE)

Please make sure you are not mixing SelfServicing and Adapter tasks. Also try to generate to an empty folder.

For the other issue, this thread could help: http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=15076

(Edit) Please make sure you are following all steps in the LinqADODSTEmplates_readme.txt file

David Elizondo | LLBLGen Support Team
Posts: 5
Joined: 19-Oct-2010
# Posted on: 22-Oct-2010 18:05:32   

Hi daelmo,

I tried but could not locate the thread that you mentioned, The code generation is being done for self servicing entities in a new folder, the tasks used in the merged preset are also of the same kind (i.e. from the Self Servicing presets). I kept the Framweork version as 3.5 as the ADO DS custom templates support that only but still no luck !

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 23-Oct-2010 06:34:37   

Sorry, The thread is private.

I will try to reproduce your problem. I never used that templates, but I will try them now.

David Elizondo | LLBLGen Support Team
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 26-Oct-2010 06:39:03   

I tested the templates in a similar scenario. No errors on the generation. No compilation errors. Please give a detailed list of steps (from the scratch) to reproduce your problem.

David Elizondo | LLBLGen Support Team
Posts: 5
Joined: 19-Oct-2010
# Posted on: 12-Nov-2010 08:39:41   

Hi All,

We have been able to get past the issue posted in the original message! The root cause of the problem was that the templates were created in an earlier version of LLBLGen and we were using LLBLGen 3.0 where the TDL template keywords have changed a bit. (Ref: http://www.llblgen.com/documentation/3.0/SDK/templates_tdl.htm )

After making some modifications to the ADO DS templates (originally posted by Brian Chance) we were able to see the preset in Code Generation Tab, the Task was also getting populated with the parameters (hence no error about SD_TemplateID) and the code generation worked without any problem. We also had to remove a few properties from the list of IgnoreProperties script to make the WCF Data Service work properly.

Thanks

Walaa avatar
Walaa
Support Team
Posts: 14986
Joined: 21-Aug-2005
# Posted on: 12-Nov-2010 09:05:56   

Good job, and thanks for the feedback.

mleeb
User
Posts: 3
Joined: 20-Sep-2009
# Posted on: 18-Dec-2010 23:42:48   

Sajjad.Nasir wrote:

Hi All,

We have been able to get past the issue posted in the original message! The root cause of the problem was that the templates were created in an earlier version of LLBLGen and we were using LLBLGen 3.0 where the TDL template keywords have changed a bit. (Ref: http://www.llblgen.com/documentation/3.0/SDK/templates_tdl.htm )

After making some modifications to the ADO DS templates (originally posted by Brian Chance) we were able to see the preset in Code Generation Tab, the Task was also getting populated with the parameters (hence no error about SD_TemplateID) and the code generation worked without any problem. We also had to remove a few properties from the list of IgnoreProperties script to make the WCF Data Service work properly.

Thanks

I am also trying to use the latest LLBLGEN download to generate a WCF Data Services / oData complaint web service in .NET 4.0 / VS 2010. Following the notes you posted in this thread, I was able to fix the initial errors using the original templates for Adapter General model by applying the DataServiceKey[] and the IgnoreProperties[] using partial classes for my generated classes:

Ex. -

[DataServiceKey("AccountId")]
    [IgnoreProperties("Fields", "ConcurrencyPredicateFactoryToUse", "AuthorizerToUse", "AuditorToUse", "Validator")]
    public partial class AccountEntity { }

However, I am now getting the "The data source must implement IUpdatable or IDataServiceUpdateProvider to support updates." when I try to call a "SaveChanges" from the client-side, so I am assuming I need the modified ADO DS templates you did above.

Sajjad.Nasir: Can you upload your latest (fixed) template?

LLBLGEN Team: Is there a template that comes out of the box now that supports generating WCF Data Services / oData complaint web service? Are there simple instructions on how to use these templates?

Thanks!

Mel

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 20-Dec-2010 14:21:03   

There are no official templates for OData support yet. There are a couple of customer contributions, which can be used as a base to build your own. We will support OData in the (near) future, however they won't make the cut for 3.1 (so it will be 3.2 or later).

Frans Bouma | Lead developer LLBLGen Pro
mleeb
User
Posts: 3
Joined: 20-Sep-2009
# Posted on: 20-Dec-2010 20:27:14   

Thank you for the quick response!

May be a somewhat similar question, but does LLBLGEN generated code support WCF RIA Services?

(ex. - In Visual Studio 2010 when you add a new "Domain Service class" for WPF RIA Services it's looking for Data Access code (such as the Entity Framework or LLBLGEN etc.) in the current project that contains DataContext/ObjectContext classes in it. So far it seems it only recognizes the Entity Framework model in the project as supporting this.)

Thanks!

Attachments
Filename File size Added on Approval
WcfRiaSupportQuestion.gif 18,116 20-Dec-2010 20:27.22 Approved
daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 21-Dec-2010 01:59:05   

mleeb wrote:

May be a somewhat similar question, but does LLBLGEN generated code support WCF RIA Services?

It will. If I'm no mistaken, for the v3.1 (http://www.llblgen.com/TinyForum/Messages.aspx?ThreadID=16377&StartAtMessage=75&#107518)

(Edit) I just realized there is a Beta version for WCF RIA Services:

WCF Ria Services support (beta) released! 17-Sep-2010

We released the first beta for the WCF RIA Services support for LLBLGen Pro Runtime Framework (v3.0). It's available for customers of v3.0 in the customer area.

The WCF RIA Services support adds full support for the Microsoft WCF RIA Services framework for the LLBLGen Pro Runtime Framework so LLBLGen Pro entities can be used in a WCF RIA services application without effort.

David Elizondo | LLBLGen Support Team
Posts: 5
Joined: 19-Oct-2010
# Posted on: 10-Mar-2011 07:40:02   

We are now getting into an issue with using $select with the WCF Data Service that exposes the LLBLGen generated model. The error message is as follows:

"The service does not expose IProjectionProvider interface which is required when top level results are paged. Request could not be processed." Stack Trace: at System.Data.Services.RequestQueryProcessor.GenerateQueryResult() at System.Data.Services.RequestQueryProcessor.ProcessQuery() at System.Data.Services.RequestQueryProcessor.ProcessQuery(IDataService service, RequestDescription description)

A little investigation using the reflector tool indicates that the error message itself might be a misleading one and actually it is an issue of using the IExpandProvider in conjunction with a query that uses Projection (i.e. $select).

my questions: 1) Is there any suggested workaround for this issue currently?

2) I saw a thread where Otis indicated that OData support might be incorporated from 3.2 onwards. Any idea whether that includes support for the $select and $expand keywords as well?

Thanks in Advance Sajjad Nasir Imran

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39760
Joined: 17-Aug-2003
# Posted on: 10-Mar-2011 14:34:49   

We do plan oData services support, but when it will arrive is not set in stone. At the moment we don't support OData services. We do support WCF Ria services in v3.1, which isn't the same thing as OData services.

Frans Bouma | Lead developer LLBLGen Pro