Browsed by
Tag: .Net

Difference between IEnumerable vs. IQueryable

Difference between IEnumerable vs. IQueryable

I was working in a .Net shop helping a medical insurance company rewrite their “legacy” system from the database all the way to the front end web site. The database was SQL Servier. The project manager was set on Entity Framework, IIS, and Web API. IEnumerable and IQueryable are both interfaces in C# that expose an enumerator and allow for iteration over a collection of objects. It is extremely important that the programmer know the difference between IEnumerable and IQueryable…

Read More Read More

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