Posts

Showing posts with the label .Net Framework

Executing a Stored Procedure....The Proper Way

As we develop in Microsoft's Entity Framework family, we will at times run into a situation, or by design, the need to execute a Stored Procedure from the database (most likely Microsoft SQL Server ).  As we have discovered, they (Microsoft) evidently do not want us to do this inherently.  They hid the direct SProc execution well down into the Database object (off the DbContext object ) and even then it has a few names: SqlQuery and ExecuteSqlCommand .  Of course, both of these have their equivalent ASync execution versions. To make matters even more fun and interesting, is the problem of Ordinal execution.  Any proper DBA will tell you, if asked, that Ordinal execution is a bad implementation pattern.  And you developers, will simply respond: Well then don't change the order in which the Parameters exist.  Then the DBA responds, and the banter battle begins between a Developer and a DBA. My simple solution to avoid this whole needless verbal battle...

Concept: Extensions

Reference:  MSDN Extension Methods (Visual Basic) Intro: While translating a C# library, i ran into a segment of code that i didnt recognize. After doing some research found out that the same design can be implemented in VB.Net (VB 2k8). One catch to the whole implementation is that the Extension development is only possible in a module. As well, there are some limitations to the design of the extension.

Dynamically Loading Controls

Recently, i ran into a situation where i needed to daisy-chain several usercontrols together. The basic thought was similar to most sites "New User Data Entry" forms. You fill one out, and then you goto the next one to fill more incriminating information and then the last form you fill out, you basically sign your life away and your first born. Problem i ran into was the fact that i could not achieve this effect without a severe overload of page resources (i.e. Multi-View/View relationship) and even then it was sadly sketchy and buggy. After doing some research and some serious code management (thats what i call it :> ) I managed to achieve a relatively small method, through VB but should be easily translatable since it is small, to get the effect i needed. 1: Friend Shared Sub NextForm(ByRef par As Control, ByRef curr As Control, ByVal [new] As String) 2: 'remove current control (curr) from parent (par) 3: par.Controls.Remove(curr) 4: 'load c...