Sep 28, 2015

New way of initializing a dictionary in C# 6.0

As I have already mention new feature list of C# 6.0 in my previous blog.

Today I am going to explore and talk about initializing a dictionary in a new way.

1. Old way to initializing a dictionary

Dictionary oldWayDict = new Dictionary()
{
    { "Name", "Kalpesh" },
    { "Surname", "Satasiya" },
    { "City", "Ahmedabad" }
};


2. New way to initializing a dictionary 

Dictionary newWayDict = new Dictionary()
{  
    ["Name"] = "Kalpesh",  //Initializing like string indexer
    ["Surname"] = "Satasiya",
    ["City"] = "Ahmedabad"
};


Here you can look at difference between old way and new way of initializing a dictionary.

Hope you like new C# features. Keep reading....

Sep 24, 2015

C# 6.0 Introduced Auto Property Initializer

Microsoft has released C# 6.0 with new features. I am going to talking about one of the new C# 6.0 feature.

Following are list of new feature of C# 6.0

  1. Auto Property Initializer
  2. Primary Constructors
  3. Dictionary Initializer
  4. Declaration Expressions
  5. Static Using
  6. await inside catch block
  7. Exception Filters
  8. Conditional Access Operator to check NULL Values
Lets start talking about first feature. Here we are looking two example of Auto Property Initializer.
1) How we are initialization property before C# 6.0
2) How we are using Auto Property Initializer in C# 6.0

Start with classic property initialization. So lets go how to used in classic way.


public class TestClass
    {
        public string Name { getset; }
        public string City { getset; }
 
        public TestClass()
        {
            //Assign value to property
            Name = "Kalpesh";
            City = "Ahmedabad";
        }
    }
Check about example, we have two property "Name" and "City". So in classic way we need to assign property value during object initialization it means under constructor.

public class TestClass
{
    public string Name { get; } = "Kalpesh";
    public string City { getset; } = "Ahmedabad";
    
}

In C# 6.0 property initializer used to below way.
Here look at above example with Property Initializer feature.

Hope developer love this feature to easy and compact property initialization.

Sep 23, 2015

SQL Server 2014 columnstore index

Today I am talking about Sql Server 2014 updatabele columnstore index. which feature Microsoft has introduced during released of Sql Server 2012.

columnstore indexes offered significant performance gains over their traditional counterparts.

Sql Server 2012 feature was introduced but some most notably point, there was no way to create clustered columnstore indexes, and the nonclustered columnstore indexes could not be updated. So whenever need to update the data, First we had to drop and rebuild the index or swap out partitions.

New release of Sql Server 2014 adds support for updateable clustered columnstore indexes. It means Sql Server 2014 has provided support for updatable columnstore indexes so you no longer have to drop and re-create columnstore indexes each time you need to load your warehouse tables.

For more detail please visit Microsoft Website

Hope database lover like this post.. Please keep reading...!!


Sep 21, 2015

Visual Studio 2015 Improvement on JavaScript Editor

Recently, Microsoft has released Visual Studio 2015 IDE with new features.

I am going to write a blog related to JavaScript editor support improvement on Visual Studio 2015.
    • Tooling Support for AngularJS: Now a days technologies moving ahead and improvement going on with new release. So its easy to writing app using AngularJS on 2015, its provides more intelliSense suggestions for Angular Controllers, Services, factories, directives and animations.

    • New JavaScript language features: JavaScript has released new version  ES6 with improvement of coding and features. So 2015 has supported including classes, arrow functions and template strings from ES6.

    • Nav bar shared project support: Navigation bar use in the shared project for windows Universal App projects.

    • New navigation bar: Now its easier to navigate between two elements in JavaScript source code using new navigation bar

    • JSDoc comments: A of the best feature of  2015 Visual Studio that supported documentation comments written in the JSDoc format are now display when using intelliSense. (Please visit for more information of JSDoc)

    • Object literal IntelliSense: Now JavaScript editor provide you with more IntelliSense feature for passing object parameter. IntelliSense suggestions when passing an object literal to functions documented using JSDoc.

    • Expand/collapse: Now JavaScript code can be more readable with this feature. This feature support at sections level as well.So now we can expand and collapse JavaScript code sections, including multi-line comments, multi-line arrays, and all multi-line blocks.

    • Task List support: Before release of VS 2015 this feature supported only server side editor but not its support to JavaScript editor as well. it means we can write //TODO and Review Comment section on JavaScript code. which will be list on Task List.

Above feature are very useful to developer during development. Its provide more intelliSense means save more time and money.

Hope each developer love this feature and useful during developement.

Hope you like this blog so keep reading... !!


Sep 16, 2015

How to integrate and customize theme in NopCommerce

Today, I am going to write blog about NopCommerce Theme integration and customization.

This blog is helpful to newbie of NopCommerce and those who have started learning NopCommerce.

First a fall download Solution from NopCommerce website. Once download, open solution on Visual Studio.

Once done, Setup and Installation of NopCommerce on your system. Browse website will be landed on home page of NopCommerce. It looks like nice and pretty layout Theme provided by NopCommerce.

So now time to integrate new Theme and Customize it.
Theme folder path in Solution-->Presentation-->Nop.Web-->Themes. Under themes folder looking "DefaultClean" theme which is provided with solution.

For example I have downloaded "NopShop" theme and copy and paste under the themes folder. Look like image ref.


Once new theme "NopShop" folder populate under Themes folder. Browse website and login to admin section and go to Admin-->Configuration-->Setting-->General and miscellaneous settings-->List theme names.

Here user can select the theme name which theme want to integrate on solution.



Now time to result on front end. Front end design will look change with new selected theme.
Once successfully integrated theme. Now time to customize it 

If you need to change any view html, copy that view file from ~/Views/FOLDER_NAME/VIEW_NAME.cshtml and paste it under ~/Themes/NopShop/FOLDER_NAME/VIEW_NAME.cshtml. For example, if you want to change the html code in ~/Views/Shared/_ProductBox.cshtml, copy that file and paste it under ~/Themes/NopShop/Shared/_ProductBox.cshtml.

If you do not need to change any view html, then modifying ~/Themes/NopShop/Content/styles.css is enough. (Also make sure you update ~/Themes/NopShop/Views/Shared/Head.cshtml to point to your NopShop theme CSS)

NopCommerce always first look for the specif view in your theme (NopShop). if it can't find than it will look into the original view at ~/Views folder file. So it means your theme view override with default views folder view. 

Hope you enjoy it and like it.


Sep 12, 2015

TRY_CONVERT() in Sql Server 2012

Sql Server 2012 many new features to the T-SQL. Some were just added from other languages and platforms to ease the transition to SQL.
Others were added to provide very powerful, new way to solve complex problems

Lets see examples of one of the feature of TRY_CONVERT().

TRY_CONVERT()

Some time CONVERT() and ISNUMERIC() is not always reliable,  So values that return are not convertible to all numeric types.

SELECT CONVERT(INT, column1)  FROM Temp WHERE ISNUMERIC(column1) = 1

 So for above statement sometime that will fail for values like 'abc' which are considered numeric but can not be converted to an integer.

but TRY_CONVERT() will give the result of  value 'abc' return NULL instead of returning an error for the entire query.

Syntax:
TRY_CAST ( expression AS data_type [ ( length ) ] )

expression
    The value to be cast. Any valid expression.

data_type
    The data type into which to cast expression.

length
    Optional integer that specifies the length of the target data type.
    The range of acceptable values is determined by the value of data_type.



Sep 10, 2015

Paging implementing on Store Procedure in Microsoft Sql Server 2012

Microsoft Sql Server 2012 introduces an interesting functionality using OFFSET  and FETCH with existing ORDER By Clause. Using OFFSET and FETCH achieving  paging functionality.

Developer can write SQL query for fetch only a set of rows from the complete result set windows and improving performance when fetching and display number of record from table.

Now time for example how to achieving paging using OFFSET and FETCH feature in Sql Server 2012.

SELECT
    Name,
    City,
    State
FROM    Customer
ORDER BY City
   OFFSET 0 ROWS
        FETCH NEXT 5 ROWS ONLY

Here if you want to write dynamic TSQL query for paging.

Declare @pageNo int =3
Declare @pageSize int =10

--Calculating OFFSET
Declare @offSet int = (@pageNo * @pageSize)  - @pageSize

Now writing above paging query with dynamic parameter.

SELECT
    Name,
    City,
    State
FROM    Customer
ORDER BY City
   OFFSET @offSet ROWS
        FETCH NEXT @pageSize ROWS ONLY


Hope you have enjoy sql server 2012 paging feature!!

Sep 9, 2015

ASP.NET 5 Cool New Feature for Missing NuGet Packages


Sometime we are tedious to fine proper Missing  NuGet Package reference on code level.

After searching NuGet Package from package Manager, require to install manually.

So Asp.Net 5 developer Provide a cool feature to help you add to add the correct NuGet Package to your projects. Which type of referencing are missing.

Whenever you will know that NuGet package are missing for your website or class library. You can just press CTRL + . (Period) to activate a helper in the editor that will offer to add the missing package to your project.


Refer image for more visual help provided editor.

Once press CTRL + . (period) editor will suggest the package which you need to add and show you the changes, that will change on using statements at the top of the code file and your code functionality working proper.

Hope you will enjoy new feature from Microsoft !!