locked
Dynamic Data with ADO.NET Data Services RRS feed

  • Question

  • User943566989 posted

    Is it currently possible to use Dynamic Data with ADO.NET Data Services? I've had a play with this to see if this would work but I didnt have much luck. I ran the datasvcutil.exe against my service (which is a  ADO.NET Data Services on a LINQ to SQL model) but I ended up with a "The context type 'Entities.NorthwindDataContext' is not supported" message.

     It seems to make sense that these technologies would work together...is there something else I am missing? Perhaps this functionality isn't supported yet?

    Thanks,

    Craig

    Wednesday, May 21, 2008 6:52 PM

Answers

  • User1641955678 posted

    Hi Craig, 

    This is a scenario that we support with the addition of a provider and a data source that are not part of the product, but that we'll give out as a sample.  In preliminary testing, it actually works pretty well.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 21, 2008 6:58 PM
  • User1641955678 posted

    Good news, you should now be able to try this (in a pretty rough early form):

    • Get the latest Dynamic Data bits from Code Gallery
    • Download the sample which name starts with MiscSamples from this page.  It's a solution with various thing, so look for "ADO.NET Data Service" in there.

    Please let us know how that works for you!

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 23, 2008 9:43 PM
  • User1641955678 posted

    As an aside to this, its seems like some of the metadata is lost from the original model (i'm guessing from the generation of the client context) and as a result, things like field lengths for strings aren't constained like they would be in a Dynamic Data project against a standard ObjectContext or DataContext.

    Yes, this is because the sample uses a simplistic modle provider which just reflects on the client context to get its information. Instead, it needs to ask the web service for its metadata (e.g. by calling DataServiceContext.GetMetadataUri), and that should contain more information.  Keep in mind that at this point, it's just a simplistic sample mostly to give an example on how to write a Dynamic Data model provider.  There are quite a few things that it doesn't handle correctly.  Hopefully, we can turn this into something more real!

    The error that was thrown when filtering was "Cannot specify query options (orderby, where, take, skip) on single resource". This error is only thrown when using forgien key filters; boolean filters like the Discontinued filter on the Product page do not throw this exception.  Interestingly, when specifying a boolean filter and a forgein key filter at the same time, a different exception is raised. In the case of Discontinued and Category filters on the products page, this error was "Property 'CategoryID' is not defined for type 'NORTHWNDModel.Products' ". Any thoughts on why this happens? I didnt get very far with my investigations as I couldnt determine the point at which the exception was being raised.

    I do see those same errors when running on the ADO.NET data service bits that come with the beta.  But when I use post-beta bits, it all works fine, so I'm going to guess it's a bug in their LINQ provider that they fixed both beta.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 27, 2008 11:32 AM

All replies

  • User1641955678 posted

    Hi Craig, 

    This is a scenario that we support with the addition of a provider and a data source that are not part of the product, but that we'll give out as a sample.  In preliminary testing, it actually works pretty well.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, May 21, 2008 6:58 PM
  • User943566989 posted

    Thanks for your quick response David, it is much appreciated.

    I'm guessing (by the mention of preliminary testing) that it would be too soon to estimate the date of a release of such a sample? I'm really curious to try it out! [:)] It sounds great, keep up the good work!

    Craig

    Wednesday, May 21, 2008 7:20 PM
  • User1641955678 posted

    The problem is that to make this work, you need a small change to System.Web.Extensions, which currently we are not including in the Dynamic Data drops (so you're using the one from the beta).  Maybe we can find a way to include that assembly in the drops to make this work.

    David

    Thursday, May 22, 2008 11:29 AM
  • User1641955678 posted

    Good news, you should now be able to try this (in a pretty rough early form):

    • Get the latest Dynamic Data bits from Code Gallery
    • Download the sample which name starts with MiscSamples from this page.  It's a solution with various thing, so look for "ADO.NET Data Service" in there.

    Please let us know how that works for you!

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 23, 2008 9:43 PM
  • User943566989 posted

    Excellent! Thanks for this!

    Its looking good so far - I havent delved into it in much depth yet!

    A few things that cropped up while playing with this.

    • Paging - The demo seems to only support next previous paging -> the default numbered paging does not seem to play nicely (perhaps due to the need for the actual record count?)
    • Sorting by description on the Categories page - a js error is thrown with the PageRequestManagerServerErrorException...but the real issue is that SQL server doesnt like sorting on the ntext column.
    • Results per page - Im not sure if this is my local build, but selecting 15 or 20 from the DDL causes only 11 records to be displayed and the footer disappears (I havent looked into whats going on under the hood yet though)
    • Filtering - The filter DDL on the List pages throw JS error with PageRequestManagerServerErrorException (I havent looked into whats going on under the hood yet though)

    Still, considering thisis an early form example, its looking very promising!

    Craig

    Sunday, May 25, 2008 5:33 PM
  • User-330204900 posted

    but the real issue is that SQL server doesnt like sorting on the ntext column.

    what version of SQL are you running?

    if you are running SQL 2005 or 2008 then nvarchar(MAX) may be able to do what you want.

    Sunday, May 25, 2008 6:25 PM
  • User1641955678 posted

    Hi Craig,

    Glad you were able to give this a try and had some good results!  Some comments:

    • Paging: this is a tricky one, because there is no way to ask for the total row count using an ADO.NET data service.  Without the row count, it's hard to know how many pages there will be.  In the sample, I put in a hack to at least allow some paging: I set the row count to one more than the current page shows, so it always claims there is one more page.  You can find this logic in Extensions\ADONetDataService\DataSource\DataServiceLinqDataSource.cs (look for TotalRowCount).  Feel free to tweak that logic to see if you can achieve a cleaner behavior.  This is really just something I put in quickly so paging is not completely broken, but it's far from perfect (it hard codes 11, which is why it's busted when you change the results per page).
    • Sorting: indeed, that's a SQL thing, and as Steve said it may behave differently in other versions.
    • Filtering: not sure what's going on here.  Please see this post on how to debug those JS errors.

    David

    Sunday, May 25, 2008 9:45 PM
  • User943566989 posted

    Thanks again for the prompt response - i'm learning so much from experimenting with these samples!

    Paging does look like a tricky scenario to cover cleanly...i'll definately be looking into this further when I get some time. Its almost a little odd that the ADO.NET data service allows for "take" and "skip" but not total row count, but I'll leave that discussion for another place/time since im sure that has/will crop up on the ADO.NET data services forums.

    With sorting, I guess i'd either change the data type as Steve suggested, or perhaps implement a custom page to prevent sorting on particular columns. As an aside to this, its seems like some of the metadata is lost from the original model (i'm guessing from the generation of the client context) and as a result, things like field lengths for strings aren't constained like they would be in a Dynamic Data project against a standard ObjectContext or DataContext. I noticed this at the same time that I noticed that the Description field does not appear within the List page for 'Categories' within a "standard" Dynamic Data project, and so had not experienced the sorting problem with them.

    The error that was thrown when filtering was "Cannot specify query options (orderby, where, take, skip) on single resource". This error is only thrown when using forgien key filters; boolean filters like the Discontinued filter on the Product page do not throw this exception.  Interestingly, when specifying a boolean filter and a forgein key filter at the same time, a different exception is raised. In the case of Discontinued and Category filters on the products page, this error was "Property 'CategoryID' is not defined for type 'NORTHWNDModel.Products' ". Any thoughts on why this happens? I didnt get very far with my investigations as I couldnt determine the point at which the exception was being raised.

    Thanks again, 

    Craig

    Monday, May 26, 2008 6:27 AM
  • User1641955678 posted

    As an aside to this, its seems like some of the metadata is lost from the original model (i'm guessing from the generation of the client context) and as a result, things like field lengths for strings aren't constained like they would be in a Dynamic Data project against a standard ObjectContext or DataContext.

    Yes, this is because the sample uses a simplistic modle provider which just reflects on the client context to get its information. Instead, it needs to ask the web service for its metadata (e.g. by calling DataServiceContext.GetMetadataUri), and that should contain more information.  Keep in mind that at this point, it's just a simplistic sample mostly to give an example on how to write a Dynamic Data model provider.  There are quite a few things that it doesn't handle correctly.  Hopefully, we can turn this into something more real!

    The error that was thrown when filtering was "Cannot specify query options (orderby, where, take, skip) on single resource". This error is only thrown when using forgien key filters; boolean filters like the Discontinued filter on the Product page do not throw this exception.  Interestingly, when specifying a boolean filter and a forgein key filter at the same time, a different exception is raised. In the case of Discontinued and Category filters on the products page, this error was "Property 'CategoryID' is not defined for type 'NORTHWNDModel.Products' ". Any thoughts on why this happens? I didnt get very far with my investigations as I couldnt determine the point at which the exception was being raised.

    I do see those same errors when running on the ADO.NET data service bits that come with the beta.  But when I use post-beta bits, it all works fine, so I'm going to guess it's a bug in their LINQ provider that they fixed both beta.

    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, May 27, 2008 11:32 AM
  • User943566989 posted

    Just out of interest, are your team still experimenting with the provider and a data source sample for Dynamic Data with ADO.NET Data Services?

    It'd be great to see the progress on this if you are [:)]

     Thanks again for all your help and advice with this,

    Craig

    Friday, June 6, 2008 11:01 AM
  • User1641955678 posted

    Hi Craig,

    It hasn't moved much since the discussion above, but it is definitely very much a goal to push this scenario forward in the next couple months.  We will probably set something up on Codeplex with a project that contains a number a new features that run on Dynamic Data v1 (aka 3.5 SP1), and this will be one of them.

    David

    Friday, June 6, 2008 11:16 AM