Coffeehouse Thread

2 posts

How to take Giant Steps today in .NET land

Back to Forum: Coffeehouse
  • User profile image
    vesuvius

    A month or so ago I posted here asking for instruction on middle tier business objects. I trawled through forums ETC and could not find any assistance.  Luckily a couple of days ago I found this.

    Being a C# head (but not averse not Visual Basic), I gave it a bash and ran into some problems. I ended up installing Visual Basic into Visual Studio to run through the app in that compiler and it worked. I have managed to get this working in C# and am over the moon. WCF and VS 2008 has greatly increased the ease with which 3 tier Service Oriented Applications can be procured and MS really need to pat themselves on the back for this (a big pat).

    Dan Wahlin has a recent post which he is teaching ADO.NET in an N-layer environment has comment in his blog from a user saying;

    I think you should drop ADO.Net 100% and move to LINQ. I suggest the same thing to everyone.

    Dan’s retort is;

    Great idea....except LINQ isn't even out yet and won't be available for use in many corporations until .NET 3.5 has been out awhile and "proven".  So, although I agree with you that LINQ should be used since it has some very cool capabilities, that's not reality for many developers at this stage of the game.

     

    My advice to you all is to JUMP on this WCF stuff (if you haven’t already). I will extol WCF with the utmost amplification henceforth and forthwith!

    If you fancy going through the WCF example in the video John Stallo has created a tutorial here. If visual basic is indigestible to you use this to convert the code if you haven’t a converter already. Incidentally the Visual Basic team really have their act together, there is a wealth of really current written and video material ready. Charlie Calvert and the C# team shame on you! Video’s available in C# land are years old, compared with Beth Massi’s nuggets (and I’m a C# guy).

     

    The only issues you will run into if you ‘follow the tutorial to a t’ are in the NorthwindDataSet. The problem is the ValidateDates(e.Row) which need to be cast as ((OrdersRow)e.Row). No idea why this isn’t a problem in visual Basic and why the cast is not required there. The solution is here;

    namespace NorthwindBusinessObjects {  

        public partial class NORTHWNDDataSet {

            partial class OrdersDataTable

            {

                public override void EndInit()

                {

                    base.EndInit();

                    ColumnChanged += new System.Data.DataColumnChangeEventHandler(OrdersDataTable_ColumnChanged);

                }

                void OrdersDataTable_ColumnChanged(object sender, System.Data.DataColumnChangeEventArgs e)

                {

                    if (e.Column.ColumnName == this.OrderDateColumn.ColumnName

                      || e.Column.ColumnName == this.ShippedDateColumn.ColumnName)

                    {

                        ValidateDates((OrdersRow)e.Row);

                    }

                }

                void ValidateDates(OrdersRow row)

                {

                    if (row.OrderDate > row.ShippedDate)

                    {

                        row.SetColumnError(this.OrderDateColumn, "Can't ship before it's been ordered");

                        row.SetColumnError(this.ShippedDateColumn, "Can't ship before it's been ordered");

                    }

                    else

                    {

                        row.SetColumnError(this.OrderDateColumn, "");

                        row.SetColumnError(this.ShippedDateColumn, "");

                    }

                }

     

            }

        }

    }

     

    Also make sure you reference both DAL and BLL in the service.

     

  • User profile image
    Dudleigh

    Full C# version available here!

Comments closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.