Posts

Unity Container implementation in MVC Application

Image
I was reading about the dependency injection and unity container for a while but never get a chance to implement it in real project. Luckily, I got a task to design a small audit application and I thought to use the dependency injection design pattern and unity container to inject the dependencies in Lazy binding manner. I just wanted to share my work with you guys so that you can also take the advantages of unity container. This post will give you the idea how to use the unity container in your future MVC project. Also, I would like to mention that I used the property injection in the example. Lets get started Step 1 – First thing first – prerequisite ·          VS 2015 ·          Unity.MVC (Get it from nuget. I used 5.0.3 version) Step 2 – Create a MVC application Step 3 – Install the Unity.MVC using nugget. After the installation you will see below files get added in project refere...

Post/Send Anonymous object to MVC/WebAPI Action/Method

I was building an MVC application where we need to give the option to the user to maintain the reference/lookup data through the UI. To active this I created different model and partial views. In order to render the partial view I need to create the different action methods and code wise it will be repetition of code. So I finalized to create one action method that take 2 parameter, the first parameter will tell me the type and second parameter will be object Type. Let me show me how I achieve this with an example. Step 1 – Model namespace WebApplication2.Models.Lookup {     public class User     {         public int UserID { get; set; }         public string UserCode { get; set; }         public string FirstName { get; set; }         public string LastName { get; set; }    ...

Get the Stored Procedure out Parameter value in SSIS using ADO.NET connection

Image
Get the Stored Procedure out Parameter value in SSIS using ADO.NET connection I am new to SSIS and recently I got an assignment to build a SSIS package to load the data in SQL database from flat file. So I created a simple package with dataflow task. Later the requirement slightly got changed and now we need to call some stored proc with OUT PAREMETER those will apply the business logic and transform the data from staging table to main table(s). In order to do this, I added couple of Execute SQL tasks to execute the stored procedure and get the output parameter value. While I was doing this I came to know that based on the connection type your SQL Statement, Parameter Mapping and some other configuration values needs to define in certain ways. I am not going to talk about those in this post. You can find them on this location. Let’s start the step by step process to call the stored process in SSIS using Execute SQL task and get the out parameter value. Step 1 – Add a ...

Reflection In C#

Image
Reflection                 This language feature allows you to inspect the assemblies’ metadata (information of types). Use of Reflection 1.        Late binding 2.        Allow to inspect the content of assembly How to use Reflection public class Program     {         static void Main( string [] args)         {             Type tp = Type .GetType( "ConsoleApplication1.Calculator" );             PropertyInfo [] pInfo = tp.GetProperties();              MethodInfo [] minfo = tp.GetMethods();             //Create Instance ...