locked
Business Logic Layer with ASP.NET totally unusable? RRS feed

  • Question

  • User260076833 posted

    Hello,

    I am always having serious problems with the "business logic layer" of my application. It's so frustrating that I am thinking about moving away from ObjectDataSource/DataSets (xsd) back to simple SqlDataSources, where the configuration is always visible to me and not hidden in tons of generated code...

    Here is what I experienced:

    A few days ago, I added a new column to a database table. To make it visible to my app, I opened the DataSet (xsd) and the TableAdapter, selected "Configure" and "Finish". The new attribute was appended at the end of the list. (I would prefer to do some kind of "reload" so that the attributes appear in the same order as in the table, but this does not seem to be possible.)

    So far so good. Today, I found that an aspx page doesn't work anymore:

    • The code sets "SelectMethod" of my data source to "GetDataByMatch".
      (A database function that tells if a single conference room matches some criteria.)
    • When evaluating the attribute "match" from the data source, I get the exception that there is no such attribute.
    • I opened the TableAdapter and the method "GetDataByMatch" and I found that the attribute "match" is missing.
      In a backup version of my project, the SQL code looked like this:
      SELECT idx, num, name, type, dbo.get_match(idx, CONVERT (datetime, @t0, 104), CONVERT (datetime, @t1, 104), @num, @bst) AS match FROM rmv_room_conference WHERE (dbo.get_match(idx, CONVERT (datetime, @t0, 104), CONVERT (datetime, @t1, 104), @num, @bst)<>'0') ORDER BY num,name;
      Here, the attribute "match" is the result from a function call. This function call was missing in the current version of my project. It must have been removed when I added the new attibute. #-) (BTW: Can you change this query so that the function will be called only once?)

    • Then, I changed the SQL code back to the code I had before. After that, I got several exceptions concerning the parameters @num and @bst that are passed to the function. The exception said, that these parameters may not be NULL. However, they really are allowed to be NULL and I remembered that I configured this in the TableAdapter's parameter collection. But here the setting "AllowDbNull" was set to false. Again, this must have happened when I added the new attribute.
      After I reset AllowDbNull to true, everything worked again!

    Well, in the meantime, touching the DataSets and TableAdapters seems to be like an adventure to me.
    Whatever I do, I always have to expect that something gets broken because of some internal, nontransparent regeneration procedures.
    This is not like working with a robust tool and a robust code base. It's more like playing cat and mouse with the IDE!

    Can I change something about this?
    How do you deal with these problems?

    Thanks
    Magnus

    Wednesday, January 13, 2016 10:04 AM

All replies

  • User-489534285 posted

    Hi Yeoman,

    When we use ready-made items then we have to use with precautions so this is also apply with ADO.Net. I can suggest either you switch to some data access library like Microsoft Enterprise Library etc or whenever you do anything handle with care.

    Thanks,

    Vijay 

    Wednesday, July 6, 2016 1:55 PM
  • User753101303 posted

    Hi,

    It seems rather a problem with the typed dataset side rather than really with ObjectDataSource etc... This is a custom SQL statement and maybe it has been reset when refreshing your typed datasets from the base table. I never really used and never liked typed datasets. I prefer either to use ADO.NET or Entity Framework. I always find typed dataset as an in between mixed approach that doesn't bring enough difference and benefit between both.

    For new application I would suggest to have a look at model binding which is available as well in Web Forms now : http://www.asp.net/web-forms/overview/presenting-and-managing-data/model-binding/retrieving-data (and so I would use "raw" ADO.NET or Entity Framework and would avoid typed dataset).

    Then I don't believe there is a "best" solution and at some point it is also my personal preference and views on the subject.

    Edit: for a low change solution another option might be to use a view or a computed column so that the tooling thinks it is just a simple table.

    Wednesday, July 6, 2016 2:38 PM