locked
Validation on backend (sql server check constraints)

    Question

  • It would be helpful to get more details on validation failures from a sql server or other database used as the backend.
    For example, when there is a check constraint on a column, Microsoft Access returns the name of the check constraint that triggered the failure (when using an access form as frontend with sql server as the backend, --i.e. ODBC linked table).  The name of the check constraint lets you know the specific column and even specific rule on that column that triggered the error. 

    This is what Lightswitch returns:
    "1 validation issue exists with data on this screen.  Click here for more details."
    After clicking:
    "[tblFoo: Data in the [tblFoo] record is invalid."
    i.e. does not give the name of the constraint, or any indication of what part triggered the error.

    Thanks.

    Friday, September 10, 2010 9:14 PM

All replies

  • Thanks for your feedback, that is a great idea. Howerver, On the Server Tier, LightSwitch relies on RIA Service and Entity Framework for CRUD operations. Therefore we are restricted by the errors that Entity Framework provides to us. I will check and see if Entity Framework can give us more information about check constraints.

    Tuesday, September 14, 2010 5:04 PM
  • Is this similar to what you're experiencing?

    http://social.msdn.microsoft.com/Forums/en-US/adodotnetentityframework/thread/5d6b8e56-8d41-493c-b4b2-92dc80832a81


    If you believe that I've answered your question, please remember to mark it as answered.

    MicroApplications, Inc. -- Information Systems Integration and Custom Software Development
    Tuesday, September 14, 2010 5:15 PM
  • Thanks.  @bbakermai, the issue is not whether I can update the database, but simply having the user receive notice of the constraint rule that is violated, so that he can take appropriate action.  
    @Huy Nguyen,
    That information is available in ms access via odbc connection to sql server; I'd assume entity framework gets at least as much information from the database server as odbc does but perhaps not.  (It would be poor practice, and prone to error, to try to duplicate the server validation rules on the client, so it would be useful to pass some of that server error information along and use the server validation mechanism.  otoh, I can see this may be sql server specific, which is fine for me but perhaps not for others, i.e. I don't know how or if entity framework can generalize constraint validation failures from different database vendors.) 

     

    Wednesday, September 15, 2010 9:17 PM
  • It's more about the wire. If you connect to EF directly in, say, a WinForms app, you're going to see errors get bubbled up directlly. If you've worked with Silverlight and WCF (with EF or L2S or whatever data access) on the server side, then you know that you have to do a little work to get a Fault back over the wire with any rich detail. I'm sure the LS team could implement some kind of SilverlightFaultBehavior (google/bing it - John Papa has a definitive article on the subject), but there isn't anything in place at the moment that I'm aware of. And I'm not sure myself how you might attach that kind of (essentially) WCF return type within a RIA Services context. Sorry I don't have a better answer regarding LightSwitch, but I wanted to illustrate where I think the challenge lies.
    If you believe that I've answered your question, please remember to mark it as answered.

    MicroApplications, Inc. -- Information Systems Integration and Custom Software Development
    Thursday, September 16, 2010 1:40 PM