Browsed by
Tag: .Net

A Stored Procedure Helper in .Net C#

A Stored Procedure Helper in .Net C#

I wrote this helper to make calling SQL stored procedures easier and less error prone. The idea here is to encapsulate the parameters of the stored procedure in an interface method that gets implemented for each stored procedure. The values of the input parameters are encapsulated in an object. It makes use of Microsoft’s (now defunct) Enterprise Library DAAB (https://learn.microsoft.com/en-us/archive/msdn-magazine/2005/august/the-enterprise-library-data-access-application-block-part-2). Here’s the interface definition: Here’s the definition of a class named “LoginParameters” that implements the interface “IPrepareSpParameterValues”. It encapsulates the…

Read More Read More

JSON Date Serialization C# Snippet

JSON Date Serialization C# Snippet

When exposing .Net DateTime members to service consumers the .Net format is not always appropriate because the consumer may not be on the .Net platform. Therefore it’s best to use the ISO 8601 standard. Serialization is performed in .Net by using the OnSerializing attribute, and deserialization by using the OnDeserialized attribute. I created a Visual Studio snippet that writes the code that enables you to serialize/deserialize your DateTime member. Once added to your Snippets library utilize it by typing “jsd”…

Read More Read More