Monday, December 24, 2018

ASP.NET MVC: HTML.ACTIONLINK VS URL.ACTION

@Html.ActionLink generates anchor  <a> tag or hyperlink on a view page in MVC whereas @Url.Action returns only a qualified URL. 

HTML.Actionlink() : 

HTMLHelper (@Html) object uses ActionLink() method to render the anchor HTML element with specified link text and action /controller name.


Here is an example of HTML.ActionLink() method to generate a hyperlink with action/controller name:

@Html.ActionLink("Home""Home""Person"

It Generates <a href="/Person/Home" >Home</a>

@Html.ActionLink("Product""Detail""Product", new { id ="5668"}, null

It Generates: < a href="https://www.blogger.com/product/detail/5678" > Product </a>


URL.Action ():

URL.Action method is used to generate the qualified URL by using the action and controller name with routes value.

Here is an example of URL.Action() method:

Url.Action("detail", "product", new { id = "5678" })

It Generates:  /product/detail/5678

More information about URL.Action @  MSDN : UrlHelper.Action Method


Friday, December 21, 2018

ASP.NET MVC : Anchor Tag IN MVC Razor View


In this blog we will discuss about the @HTMLHelper class and how to create the HTML Anchor by using @Html.ActionLink.

@HTMLHelper Class:

@Html is used in ASP.NET MVC to render HTML elements like TextBox, Button etc. and it binds the model object to HTML control and display the object’s value and while posting the page, it binds the control value to model object.


@Html.ActionLink Method:

HTMLHelper object has ActionLink method to render the anchor HTML element with specified link text and action name with controller.


Here is examples of Action methods:

·        @Html.ActionLink("Home""Home""Person"

Generates <a href="/Person/Home" >Home</a>


·         IF you are not passing controller, by default it will take current page controller name.


    @Html.ActionLink("Home""Home")


·         Action and Controller with parameter are given:


@Html.ActionLink("Home""Home""Person"new { PersonID = Model.ID}, null )


Generates <a href="../Person/Home?PersonID=1212" >Home</a>


·         Anchor with html ID


@Html.ActionLink("Home""Home""Person"new { PersonID = Model.ID}, new { id = "HomeLinkID"} )


Generates <a href="../Person/Home?PersonID=1212" id="HomeLinkID" >Home</a>

Thanks for visiting!!

Thursday, December 13, 2018

SSIS: Dynamic File Name for Flat File Destination


This blog will demonstrates how to give the dynamic file name for flat or csv  file in SSIS package  like DataFeed_{yyyyMMdd} .txt eg. DataFeed_20181212.txt




Data Flow
Data Flow

  • Configure the Flat File Destination with dummy file name.
Flat File Connection Manager
Flat File Connection Manager
  • Go to Connection Manager and right click on Flat File Connection Manager

    1. Click on Property
    2. Set DelayValidation = True, by default it is False

Flat File Connection Manager Property
Flat File Connection Manager Property
  • Click on Expression Property and Set Expression Value for ConnectionString 


Expression Builder
Expression Builder































Expression:

"C:\\temp\\dataFeed_"+(DT_STR,4,1252)MONTH( DATEADD( "dd", -1, getdate() )) +(DT_STR,4,1252)DAY( DATEADD( "dd", -1, getdate() )) +(DT_STR,4,1252)YEAR( DATEADD( "dd", -1, getdate() ))+".txt"


·   (DT_STR,4,1252)MONTH( DATEADD( "dd", -1, getdate() )) – returns Month
·   (DT_STR,4,1252)DAY( DATEADD( "dd", -1, getdate() )) – returns day
·   (DT_STR,4,1252)YEAR( DATEADD( "dd", -1, getdate() )) – returns Year
  
The above expression generates file name dataFeed_MMDDYYYY.txt in C:\temp location.


Thanks for visiting and please leave your comment if it helps you

Tuesday, December 11, 2018

SSRS : RDLC - NULL Check, Date Format and Concatenate of Fields

this blog discuss about the basic operation like how to concatenate two fields or NULL check or convert string into uppercase or format date/time field in rdlc .

Concatenate two Fields Value :  
We can simply concatenate two string field as below

Example:
 =Fields!Description.Value +"("+Fields!Code.Value+")"

NULL Check of Field Value:
We can use IS Nothing statement to check field NULL value.

Example:
 =iif(Fields!Letter.Value Is Nothing, “No Letter Found”,Fields!Letter.Value)



Date Format:
We can use FormatDateTime() function to format date/time field value.

Example:
=FormatDateTime(Fields!OrderDate.Value, DateFormat.ShortDate))

Options for Dateformat : 
  • GeneralDate
  • LongDate
  • ShortDate
  • LongTime
  • ShortTime 
UpperCase of Field Value:
We can use  UCase() function to convert the string or character containing the specified string  into uppercase.

Exmaple :
=UCase(Fields!Description.Value)

Thanks For Visiting !!

Visual Studio SSIS Project Incompatible


Unsupported
This version of Visual Studio is unable to open the following projects. The project types may not be installed or this version of Visual Studio may not support them.
For more information on enabling these project types or otherwise migrating your assets, please see the details in the "Migration Report" displayed after clicking OK.

I recently faced this issue, when I tried to open existing SSIS project and it was not opening in Visual Studio 2017 and throwing ‘Unsupported Message’.
When I migrated current project from visual 2015 to visual 2017 and I found that SSIS /SSRS component is not part of Visual studio 2017 installation package so I installed separate package for SSIS/SSRS and after sometimes visual studio (in background ) runs some performance improvement update checks and it asks to disabled the 3rd party component and after that SSIS package was not loading in visual studio solution  and throwing above unsupported error message.



 I followed below steps to resolve this problem. 

Click on Tools à Extensions and Updates … Option 

Extensions and Updates
Extensions and Updates


Extensions and Updates Screen:
  
Extensions and Updates







Click on “Enable” button to include package in project, after that close visual studio solution and reopen the SSIS project.


Thanks for visiting and please leave your comments, if it helps you

Tuesday, November 27, 2018

Perform Load testing for Web API /Restful service in Postman

This blog demonstrates how to perform load testing of WEB API (restful service) by using postman tool.

Steps:
  1.  Create a Collection.
  2. Add Web API HTTP Request.
  3. Run ‘Runner’ to perform load testing.

Create a collections – which contains list of HTTP request

Ø  Click on New Button icon under Collections Tabs


 Postman Create a Collection


Ø  “Create a New Collection” screen will be displayed

 Postman Create a Collection


Add Web API HTTP Request:

Ø  Click on New Button:

Add Web API HTTP Request


Ø  Click on  “Create New -> Request (Under Building Block)” icon


Add Web API HTTP Request:

Ø  Save HTTP Request to ‘Load Restful Web APIs’

·        Give HTTP Request Name eg. HTTP Get Request

Add Web API HTTP Request:



·        Enter Web API URL and required information to submit request


Enter Web API URL


Run ‘Runner’ to perform load testing:

Ø  Click on “Runner” Button

Run ‘Runner’ to perform load testing:

Ø  Select Collection and provide value for below fields:
·        Environment
·        Iteration
·        Delay    

Collection Runner


Ø  Click Start RUN & after successfully RUN, will be display Load balance test result:

Load balance test result


Monday, November 26, 2018

Web API over WCF

While designing the service layer for new application, this debate is always happened in my team.

        Are we going to choose Web API over WCF or going with WCF?

Choosing right technology always contribute the major role of the success of application. If without understanding all possible factor and product requirement, you cherry-picked any technology, it could be a reason for application failure or performance issue and also it could limited the exposure of client.  

Let back on our topic ‘Web API vs WCF’. there is no doubt, WCF provides a lots of feature and it is much more versatile in case of supporting to many transport protocols (HTTP, TCP, Named Pipes etc.) and can easily build secure, reliable and transaction enabled service and much more in messaging like two –way communication (duplex channel) .

Web API if you need to build  a lightweight, restful service based HTTP protocol and it can leverage of the full feature of HTTP protocol like cache control, versioning etc and you want to expose your service to a broad range of client i.e. web browser, tables, mobile then web API always have advantage over WCF. WCF has very extensive configuration compare to web API and WEB API is very simple and light weight service and easily accessible in limited bandwidth device like smart phones and tablet. Web API supports any text format including XML so in performance, Web API is faster than WCF.

WCF:

WCF
WCF

·         Should support special scenarios such as one way messaging, message queues, duplex communication etc.
·         Should support fast transport channels when available, such as TCP, Named Pipes, or maybe even UDP (in WCF 4.5), and you also want to support HTTP when all other transport channels are unavailable.
·         Should be transaction enabled service or it will be called under other transaction scope.

Web API:


Web API
WEB API

·         Should be restful service over HTTP that can use the full features of HTTP (like URIs, request/response headers, caching, versioning, various content formats).
·         Should be expose your service to a broad range of clients including browsers, mobiles, iPhone and tablets.

Thanks for visiting !!

Tuesday, November 6, 2018

C# - Polymorphism

Polymorphism is major concept of object programming and in general term, it stands for ‘Many Shape’, it means the one function can perform different thing depend on context.
In C#, Polymorphism can be categories in two group.
·                   Static Polymorphism
·                   Dynamic Polymorphism


Static Polymorphism:

In Static polymorphism, the calling method will be decided on compile time so it is also called Early Binding. In C#, it will be achieved by Function Overloading or Operator Overloading

Function Overloading: we can defined multiple function with same name but its signature will be different, it is called function overloading. In method signature, we are not considering return type.

The following code shows How same function ‘Render()’ render different shape based on passed input type ( Circle,  Rectangle).

public class RenderShape
    {
        public void Render(Circle circle)
        {
            Console.Writeline("Rendering Circle");
        }

        public void Render(Rectangle rectangle)
        {
            Console. Writeline ("Rendering Rectangle");
        }
    }

    public class RenderEngine
    {
        public void Render()
        {
            RenderShape renderShape = new RenderShape();

            renderShape.Render(new Circle());

            renderShape.Render(new Rectangle());

        }
    }


Output:

Rendering Circle
Rendering Rectangle



Dynamic Polymorphism –

In Dynamic polymorphism, the calling method will be decided on runtime so it is also called Late Binding.  In C#, it will be achieved by implementation of Abstract Class or Interface.

Abstract:  
In C#, Abstract class is used for partial implementation and it contains abstract method, which must be implemented by derived class eg. Circle, Rectangle. Abstract class can have some common code, which will be shared among all derived class.


        public abstract class Shape
            {
                public abstract void Render();
            }

        public class Circle : Shape
        {
            public override void Render()
            {
                Console.Write("Rendering Circle");
            }
        }

        public class Rectangle : Shape
        {
            public override void Render()
            {
                Console.Write("Rendering Rectangle");
            }
        }

  
       public class RenderEngine
        {
            public void Render()
            {
                Shape shape = new Circle();
                shape.Render();

                shape = new Rectangle();
                shape.Render();
            }
        }


Interface:
Interface is a basically contract, which have only signature of methods or property. the class which will be implement this interface have to define the signature.


        public interface IShape
            {
                void Render();
            }


        public class Circle : IShape
        {
            public void Render()
            {
                Console.Write("Rendering Circle");
            }
        }

        public class Rectangle : IShape
        {
            public void Render()
            {
                Console.Write("Rendering Rectangle");
            }
 }

        public class RenderEngine
        {
            public void Render()
            {
                IShape shape = new Circle();
                shape.Render();

                shape = new Rectangle();
                shape.Render();
            }
        }


Thanks for visiting !!

SQL Server - Identify unused indexes

 In this blog, we learn about the index usage information (SYS.DM_DB_INDEX_USAGE_STATS) and analyze the index usage data (USER_SEEKS, USER_S...