locked
Dynamic Data with ASPNET Data Service-Nullable Fields RRS feed

  • Question

  • User1450188179 posted

     Hi,

    Firstly if this has been asked before, my apologies, but the forum search feature seems to be on holiday or strike today [:(]

    I have downloaded the  Dynamic Data Futures samples and am looking at the Dynamic Data site using the ASPNET Data Services provider and I have a stupid question/problem:

    Problem: All fields seem to be being treated as required, even if they are nullable??

    Example:

    Open the DD site, navigate to the Suppliers Table, click edit, make no changes, then click update. You get a validation message for each blank field saying that it is required.

    Checking the schema (edmx) on the Data Service this is not correct. Example: Fax column is nullable in schema but throw false validation warning.

    OK, so maybe the proxy is lacking enough info, checking (again the Fax column) the property shows no info on being Nullable or otherwise.

    Perhaps it is my job to annotate the nullability?? However the System.ComponentModel.DataAnnotations.RequiredAttribute takes no parameters so marking this 'false' must be done by omission.

    Am I missing something??

    Also, just a thought, but will the DataSvcUtil proxy generation tool be amended so that we can decorate the 'Source' schema (ie the code file on the edmx) with and have these propogated/generated to the proxy file? On second thoughts, perhaps this is a client issue and should be done on a partial class of the proxy? Not sure which way this seems best, just want to avoid having to redecorate all the time [:)]

     Cheers

    Simon

     

    Saturday, October 4, 2008 12:44 AM

Answers

  • User1641955678 posted

    Hi Simon,

    This issue should be fixed in the version of the data source that I sent you (relating to your other issue about foreign keys).

    thanks,
    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 15, 2008 4:49 PM

All replies

  • User-330204900 posted

    My first request would be have you tried a site based on Northwind? the Orders table will pretty much let you enter a blank record [:D]

    Saturday, October 4, 2008 5:29 AM
  • User1450188179 posted

     Hi Steve,

    Yes I am using the Northwind DB, and the  Dynamic Data Futures sample from CodePlex. That is: this solution is straight out of the MS box. The only thing I have changed is to put the correct path to the Northwind DB.

    I have looked at Orders table and the Suppliers table and both exhibit this behaviour.

    All I am doing is clicking the Edit link on an existing record and then clicking the update link, ie trying to put the same data back in, as is already there.

     

    Cheers

    Simon

    Sunday, October 5, 2008 4:54 PM
  • User-330204900 posted

    That' very unusual I've got Northwind all over the place and no issues at all, I'll just try DD Futures project and see if there are any issues there [:D]

    Sunday, October 5, 2008 5:45 PM
  • User1450188179 posted

    I have spent a bit more time investigating. There is definitely a bug somewhere because when a put a break point in the Text_Edit.ascx.cs and inspected the attributes from:

     ?this.Host.Column.Attributes

    All the columns show the RequiredAttribute as being set. Eg for ShipRegion it happens to be the 6th attribute:

    ?TextBox1.ClientID
    "ctl00_ContentPlaceHolder1_GridView1_ctl05___ShipRegion_TextBox1"

    ?this.Host.Column.Attributes[5].GetType().FullName
    "System.ComponentModel.DataAnnotations.RequiredAttribute"

     

    This is the case for all the columns I check from the Northwind Dynamic Data  Data Service sample.

    Is this an issue that anyone from the Dyanmic Data team can shed any light on.

    Cheers

    Simon

    Tuesday, October 14, 2008 3:49 PM
  • User-330204900 posted

    Are you using DD from SP1 or is it an old app from an earlier release. I'm using DD and I have no issues like yours I'm using Northwind and I can have null fields none required fields etc.

    I'm sure that there is something wrong with your project. [:D]

    Tuesday, October 14, 2008 4:18 PM
  • User-1005219520 posted

    Hey Simon,

    I can't reproduce the problem. To simply what is going on, can you create a Dynamic Data web site with the NorthWind DB. Just add the Suppliers table. Let me know if you are using L2S or EF. Provide as much detail as you can to reproduce the problem. Like Steve said, we use NW a hundred times a day with no problem. You can easily get the error you mentioned by removing constraints from  DB, creating the data model, then adding the constraints.

    Tuesday, October 14, 2008 7:33 PM
  • User1450188179 posted

     Hi Rick,

    Thanks for you response. 

    Firstly, are either of you or Steve using DD against a ADO.NET Data Service rather than L2S classes or EF classes??

    Just to clarify I am not using either EF or L2S. I am using the ADO.NET Data Services sample projects in the CodePlex DynamicDataFutures solution, the release from DynamicDataFutures0716.zip. I have VS2008 SP1, netfx 3.5 sp1.

    There is a DataServiceContext that uses DataServiceQueries and there is a derived DataServiceLinqDataSource (derived from but LinqDataSource)...

    Also therefore all the metadata is coming from a client proxy derived from DataServiceContext not from L2S or EF  classes directly. On the server side there is an EF edmx model etc.

     I have not created any projects, I am using the  sample solution straight from codeplex.

     Steps to reproduce:

    1. Open the Dynamic Data Futures solution

    2. expand the 'ADO.NET Data Service' solution folder

    3. expand the DataServiceSite project, right click the Northwind.svc file and choose 'View in browser' to get the data service running in the WebDev server.

    4. expand the sibling DynamicDataClientSite project

    5. right click the Default.aspx file and choose 'view in browser'

    6. on the default page, click on  the orders table link

    7. On the ListDetails.aspx page, choose an order with a blank column eg order num 10251, click edit.

    8. Make no changes, click update

    I receive these validation warnings:

    List of validation errors

    • The ShipRegion field is required.

     

    This is unexpected, because the entity model does not reflect this requirement either in the proxy or the edmx.

    Please let me know if you can repro this using the above settings.

    I don't think it is a problem with NW, it is a problem with some client side MetaColumn or MetaTable provider as the RequiredAttribute incorrectly shows up on each column. 

    As you both rightly point out the other project DynamicDataFuturesSample that has the L2S classes in it does work perfectly.

    If you cannot repro this then I must have something wrong with my environment.

     

    Cheers

    Simon

     

     

     

    Tuesday, October 14, 2008 10:15 PM
  • User-1005219520 posted

    Thanks for the detailed instructions Simon. I have reproduced the problem.  We will investigate and report back.

    Tuesday, October 14, 2008 10:31 PM
  • User1641955678 posted

    Hi Simon,

    This issue should be fixed in the version of the data source that I sent you (relating to your other issue about foreign keys).

    thanks,
    David

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, October 15, 2008 4:49 PM