Tuesday, December 30, 2014

C# 6.0–Null conditional operator

This blog post is part of C# 6.0 Features Series.
As we know there are lots of small features added in C# 6.0 and Null conditional operator is one of them. You can check null with specific conditions with Null conditional operator and this will definitely increase productivity of developers and there will be less lines of code.

Let’s create example. Following are two classes I have created for this example. Address class will contains two properties like Street and City.
namespace NullConditionalOperator
{
    public class Address
    {
        public string Street { get; set; }
        public string City { get; set; }
    }
}
And Same way Person class contains four properties Id,FirstName,Lastname and Address which is of type Address class which we have created.

Share:
Sunday, December 28, 2014

C# 6.0–Static class using statement

This blog post is part of C# 6.0 Features Series.
C# 6.0 version introduced lot of small features and one of that features is  using feature. Now with C# 6.0 you can use using statement which was not possible in earlier versions of  C#. Following is a example of using statement in C#.
using static System.Console;

namespace StaticClassUsing
{
    class Program
    {
        static void Main(string[] args)
        {
            WriteLine("With using statement");
        }
    }
}
And below is output when you run your application.

Share:

C# 6.0–Auto implemented property initializer

This blog post is part of C# 6.0 Features Series.
As we all know C# 6.0 is there in preview mode and Microsoft has added few small features to C# 6.0 which helps  lot while you develop application. In today’s blog post we are going to learn one more small feature called “Auto implemented property initializers”.

Developers working on C# used a automatic properties a lot and there has been lot of demands from developers that automatic properties should a have initializers and Microsoft has listened to that feedback and with C# 6.0 it has been introduced. So now we don’t have to use constructors to initialize automatic properties and there will be less and much cleaner code for Automatic property initializations.

Share:
Saturday, December 27, 2014

Continuous Integration with visualstudio.com,Unit Test(Test Driven Development) and TFS


Before some time I have written a blog post about Continuous integration with visualstudio.com and TFS and It goes quite a good number visits and lots of people are asking for unit test integration with continuous integration too. Today one of colleague also asked for the same. I thought it will be good idea to write a Blog post about it.

In this blog post we are going to create a new MVC application with a Test Project so that we can run tests and configure unit test with continuous integration. So Let’s first create a new application in visual studio.com.

New-Project-unit-test-continious-integration

Share:
Friday, December 26, 2014

Colorized tooltip in visual studio 2015

Visual studio 2015 provides lots of new features and Colorized tooltip is one of the features that I really like. As we all know that Visual studio supports automatic collapse of various language constructs like classes, methods.  When you mouse hover it automatically show hidden code presented in that portion.

In earlier version of Visual Studio that tooltip was shown with hidden code but it was in plain text. Now this tooltip is colorized with syntax highlighting so your hidden code is more readable.It’s look like below.

colorized-tooltip-visualstudio2015

Hope you like it. Stay tuned for more. I’m going to post lot more blog post about new Visual Studio 2015 features.
Share:

C# 6.0–nameof Operator

This blog post is part of C# 6.0 Features Series.
Microsoft announced the new version of C# 6.0 at the day of visual studio connect event on November. They have not added any big features to C# 6.0 but they have listened to community and added few small features which comes really handy. One of the that is nameof operator.  In this blog post we learn why nameof operator is very useful.

Let’s create a class Employee with few properties.
public class Employee
{
    public string FirstName { get; set; }
    public string LastName { get; set; }
}
Now what I want to do here is to create a object with object initializer and print values of properties with print method.

Share:
Thursday, December 25, 2014

Custom Windows Layout in Visual studio 2015

Visual studio 2015 preview has been released by Microsoft before some days. So I recently got installed in my machine. It contains a bunch of new features and we are going to explore it one by one. Custom layout windows in visual studio 2015 is a one of the nice features in list. In this blog post we are going to learn about custom windows layout in Visual studio 2015.

As we all use different kind of devices like laptop, desktop and some times we choose our visual studio layouts based on screen size and resolution of monitors.   We generally moved items like solution explorer, Team explorer and toolbox based on space available and resolutions of devices. Personally When I work on desktop where I have 22 Inch monitor I used to prefer my solution explorer and other windows open while when I work on laptop which got 15 inch screen all the windows will be in collapse mode.  In this kind of scenario this features comes quite handy.

Let’s see how its works. Here’s is my laptop layout where I like all the windows in collapse mode and I will open windows as I need them.

Share:
Sunday, December 14, 2014

Continuous integration with visualstudio.com and TFS


As a developer, we all are using some kind of source control provider to maintain versions of our source code.  But another aspects of source control to is to make sure that code committed in source code repositories are  perfect and it will not break the build of particular software. That’s why Continuous integration is very much popular this days.

What is Continuous Integration:


As per wikipedia
Continuous integration (CI) is the practice, in software engineering, of merging all developer working copies with a shared mainline several times a day. It was first named and proposed by Grady Booch in his method, who did not advocate integrating several times a day.
In simple words, when developers checks in or commit code to source code repository a build of software will automatically triggers to check whether current check-in/commit of code breaks code or not.

Share:
Saturday, December 13, 2014

1.5 million page views for my blog- dotnetjalps.com

Ahh, still it’s hard to believe that my blog has achieved this milestone. Yeah my blog got completed 1.5 millions page views. So first all, thank you readers without you guys it’s not possible to achieve such a big milestone.

When I started my blog I was not never sure what I am going to do with this blog. But then it’s become integral part of my life. Now I can’t imaging my self without my blog.
A big thank you to all who supported me and given so much love to my blog.
I would also like to thank you my family without their support it was not possible to achieve such a big milestone.

Before some time I have written a blog post about 1 million view. It took almost four years to achieve 1 million page views mile stone and now this time it cross half million in just about 7 months( May 2014 to Dec 2014). So again thank you very much dear readers for making my blog popular.

Statistics from blogger.com:


I am not super crazy about sharing statistics but this is a special milestone I am sharing my statistics with you guys. Following is a statistics confirmed by blogger built in statistics tool.

Share:
Tuesday, September 16, 2014

Complex type in EFCodeFirst

I have already written a few blog post about EF Code first and it’s features following is a complete list of blog posts.

Entity framework code first and inheritance- Table Per Type
Entity Framework code first and Inheritance–Table per hierarchy
Entity Framework Code First migrations
Different way of mapping with EFCodeFirst
Different way of creating keys in EFCodeFirst

This post will also be part of this EF code first series. In this blog post we are going to learn how we can handle complex type in EF Code First. In our day to day operation we are having different kind of database tables where  there are multiple type of relationships  are defined like one-to-one, one-to-many and many-to-many. This all kind of relationship is handle by complex types.

Share:
Thursday, September 11, 2014

Dependency Injection with ASP.NET MVC and Simple Injector


I have been learning SimpleInjector for few days and it’s just awesome.  I have already written two post about it(see below link) and this post will be third post about it. In this post we are going to learn how we can do Dependency Injection with ASP.NET MVC.

For those who are reading my posts about Simple Injector Following are two previous post I have written about Simple Injector. I highly recommend to read first two post so that you can be aware about how we can configure SimpleInjector container.

Dependency Injection with Simple Injector
Singleton Instance in Simple Injector

So let’s start with creating a ASP.NET MVC Project from Visual Studio.



Share:
Tuesday, September 9, 2014

Singleton Instance in SimpleInjector

Before some time I have written a blog post Dependency Injector with Simple Injector. This is a second blog post in same series. In this blog post we are going to learn How we can create a singleton Instance in Simple Injector.

What is is Singleton:


This is one of the Gang of Four creational pattern. Idea of behind the singleton pattern is to have only one instance of class of at anytime. This pattern ensures that a class will has only one instance of it and provides a global point of access to that instance.

I have already written a global blog post about that. You can find a basic example of Singleton pattern in C# from the following link.

Singleton Class in c#

How we can create Singleton Instance with SimpleInjector:


Here I’m going to create a console application with logger example. So let’s create via creating a new project like below.

Share:
Friday, August 29, 2014

Dependency Injection with Simple Injector

Before some I have written a blog post about how to do dependency injection with StructureMap. In this post we are going to learn Simple Injector IOC library and how we can do dependency injection with Simple Injector.

About Simple Injector:


Simple Injector is a open source dependency injection library developed with C#. Followings are few characteristics of Simple Injector.
  • Simple Injector is very simple to use dependency injection library support .NET 4+ framework, Silverlight 4+, Windows Phone 8, Windows 8 Including Universal apps and Mono.
  • Simple Injector is easily integrated with frameworks like ASP.NET Web Forms, ASP.NET MVC, ASP.NET Web API, WCF and many more.
  • It’s free and always be free. Published under MIT license.
  • Simple Injector is highly optimized for performance and concurrent use.
  • Simple Injector is thread safe and lock free design.
  • Simple Injector has great support for generics and used lot of things of generics then any other dependency injection libraries.
  • Simple Injector has a powerful diagnostic system.Currently it offers following validations
    • Lifestyle Mismatch
    • Short Circuit Dependencies
    • Potential Single Responsibility violations
    • Container Register Types
  • Simple Injector is amazingly fast.
  • Simple Injector is developed using Modern proven development practices such as TDD and Solid Design Principals.

Share:
Saturday, August 23, 2014

Stackoverflow.com like URLs with attribute routing in ASP.NET MVC

Before some time I have blogged about Attribute Routing features of ASP.NET MVC 5.x version.  In this blog we are going to learn how we can create stackoverflow.com like URLs with attribute routing.

As you know www.stackoverflow.com is one of the most popular questions answer site where you can ask questions and almost get the answers of your questions. So to create URLs like www.stackoverflow.com we need to understand structure of URLs of Stackoverflow. Let’s take example of following question URL which I have answered on stackoverflow.com

http://stackoverflow.com/questions/24133693/can-i-use-signalr-2-x-with-net-4-0-if-i-am-using-microsoft-bcl-upgrading-from

and let’s take another example

http://stackoverflow.com/questions/23739256/the-advantage-of-formsauthentication-class-over-session-variable

If you compare and understand structure of this URLs. You will know that there will be a two things which will be dynamic for this URLS.

Share:
Thursday, August 21, 2014

Blog post selected as ASP.NET MVC Official Additional Learning Resources

I have got news before few days that my blog post about CDN is ASP.NET MVC bundling selected as Additional Resources for learning about ASP.NET MVC on official ASP.NET Site.

On this occasion I would like to thank my audience and my family to supporting me. Thank you all without you it would not have been possible. I loved to be part of this amazing community and I promise that I would continue to do community work.

I would also like to thank Rick Anderson and Jon Galloway and whole ASP.NET Team for selecting my post. It’s a honour for me. Thanks you very much guys for encouraging and inspiring me  to do community work!!

Due to all this my blog got high ranking and I’m almost getting more then 80k page views every month. Google is loving my blog more and more!!
CaptureBlog

Thank you very much everything dear readers!!
Share:
Friday, August 1, 2014

Different way of creating keys in EFCodeFirst

Recently I have been playing with Entity Framework Code First and I like it a lot. There are plenty of features given and you can configure all that stuff with code. I have already written couple of post for Entity Framework Code First.

Different way of mapping in EFCodeFirst
Entity Framework code first and Inheritance–Table per hierarchy
Entity framework code first and inheritance- Table Per Type

As you EFCodeFirst generate database table based on the configuration defined in classes. Today we are going to learn about how we can create key with different configurations.

Share:
Tuesday, July 29, 2014

CDN in ASP.NET MVC bundling

ASP.NET MVC contains great features and Bundling is one of them. The Bundling and Minification features allow you to reduce number of HTTP requests that a web page needs to make by combining individual scripts and style sheet files. It can also reduce a overall size of bundle by minifying the content of application.   From ASP.NET MVC 4 bundling also includes CDN support also where you can utilize public CDN available for common libraries. Let’s look this features in details.

CDN Support in Bundling:


Libraries like jQuery, jQuery UI and some other libraries are commonly used in most of the applications. There are available in CDN (Content Delivery Networks) specifying the URL of particular library with specific version.  Bundling now has CDN path as parameter in default bundle functionality where you can specify the path of the CDN library and use that. So when you application run in production environment first it will check whether CDN are available or not if available then it will load it from the CDN itself and If CDN is not available then it will load files hosted on our server.

Share:

CRUD Operation with ASP.NET MVC and Fluent Nhibernate.

Before some time I have written a post about Getting Started with Nhibernate and ASP.NET MVC –CRUD operations. It’s one of the most popular post blog post on my blog. I get lots of questions via email and other medium why you are not writing a post about Fluent Nhibernate and ASP.NET MVC. So I thought it will be a good idea to write a blog post about it.

What is Fluent Nhibernate:


Convection over configuration that is mantra of Fluent Hibernate If you have see the my blog post about Nhibernate then you might have found that we need to create xml mapping to map table. Fluent Nhibernate uses POCO mapping instead of XML mapping and I firmly believe in Convection over configuration that is why I like Fluent Nhibernate a lot. But it’s a matter of Personal Test and there is no strong argument why you should use Fluent Nhibernate instead of Nhibernate.

Fluent Nhibernate is team Comprises of James Gregory, Paul Batum, Andrew Stewart and Hudson Akridge. There are lots of committers and it’s a open source project.

You can find all more information about at following site.

http://www.fluentnhibernate.org/

On this site you can find definition of Fluent Nhibernate like below.
Fluent, XML-less, compile safe, automated, convention-based mappings for NHibernate. Get your fluent on.
They have excellent getting started guide on following url. You can easily walk through it and learned it.
https://github.com/jagregory/fluent-nhibernate/wiki/Getting-started

ASP.NET MVC and Fluent Nhibernate:


So all set it’s time to write a sample application. So from visual studio 2013 go to file – New Project and add a new web application project with ASP.NET MVC.

Share:
Saturday, July 26, 2014

Different way of mapping with EFCodeFirst

Recently I have been working Entity Framework Code First 6.0 and it’s awesome. I am in love with it. It has got great fluent API and we can do anything with that. It’s also promotes Convention over configuration which I love so far.

I have seen people are more confused about how we can map table to class via Entity framework via code first. So this post is going to be in same series. In this post I’m going to write about different ways to mapping table to class. I have already written two post about in details.

Entity Framework code first and Inheritance–Table per hierarchy
Entity framework code first and inheritance- Table Per Type

In this blog post I will give you tips and tricks to map class(type) with database table.

Share:
Thursday, July 24, 2014

HashSet in C#

In this blog post we are going to learn about HashSet collection in C#. It is a cool collection available from C# 3.5. Like any other collection it can be used for representing a set of value. It is an optimized set collection. It helps eliminating duplicate string or elements in collection. Whenever an Item is added in collection it will check whether this items are already there in collection If not then only it will add items.

Let’s take an example for the same.
using System;
using System.Collections.Generic;

namespace CSharpHashSet
{
    class Program
    {
        static void Main(string[] args)
        { 
            HashSet<string> nameHashSet=
                new HashSet<string>
                {
                    "Jalpesh", "Vishal", "Tushar", "Jalpesh"
                };
            foreach (var item in nameHashSet)
            {
                Console.WriteLine(item);
            }
            Console.ReadKey();
        }
    }
}
Now if you see the code carefully I have created HashSet of name(string type) with duplicate name like “Jalpesh” and then enumerate that collection with for loop and print items of collection with Console.WriteLine.

Share:
Wednesday, July 23, 2014

StructureMap–Getting Started

In this post we are going to learn about How we can do dependency injection with StructureMap. Here we are going to take a sample application of shopping cart. This shopping cart can process two type of orders 1. Sales order 2. Purchase Order. We want an abstraction for this. So first we are going to create an interface IOrder which will be implemented by both Purchase Order and Sales Order classes.

Following is a code for that.
public interface IOrder
{
    void Process();
}
And following is a implementation of SalesOrder class.
public class SalesOrder : IOrder
{
    public void Process()
    {
        Console.WriteLine("Sales Order Processed");
    }
}
Same way following is a implementation of PurchaseOrder class.
public class PurchaseOrder : IOrder
{
    public void Process()
    {
        Console.WriteLine("Purchase Order Processed");
    }
}
And following is a code for Shopping Cart.
public class ShoppingCart
{
    private readonly IOrder _order;
    public ShoppingCart(IOrder order)
    {
        _order = order;
    }

    public void CheckOut()
    { 
        _order.Process();
    }
}

Share:
Sunday, July 20, 2014

Entity Framework Code First migrations

In this blog post we are going to learn about entity code first migrations. Entity Framework code first approach will allow you to define model classes as per the domain requirements via POCOs. Hence you have complete control over classes are written. But as application grows and there are some new features to be added and  your classes will change. Entity Framework Code Migrations allows you to handle this migrations.

As we all now that Entity Framework Code First approach allows you to create database based on your classes created. It’s provide you three types of initializers.

CreateDatabaseIfNotExist: This is the default initializer which will create classes if database not exists.

DropCreateDatabasesWhenModelChanges: This initializer is only good when you don’t concern about your database records. If there is any change in class then it will match database will classes and if there is any difference then it will drop and create a new database.

DropCreateDatabaseAlways: This initializer will always create new database whether database exist or not. If database exist then it will drop that database and create it again.

Share:

Visual Studio 2013, Team Explorer and BitBucket

With Visual Studio 2013, Microsoft started supporting Git directly with Team Explorer  and I have written a blog post how we can use git with team explorer and github called Visual Studio 2013, Team Explorer and GitHub. This post gained lots of popularity and also get lots of email about writing a blog post for using Git With BitBucket.org which is similar kind of source code hosting service like GitHub.com. So this post is all about it.

In this post I’m going to use a sample console application where we will put some code and then publish it to BitBucket Git Repository.  In this post I’m going to slightly take different approach then previous post but still you can do same way also previous post also.

In this post first we are going to create repository in BitBucket and then clone it on local. So here people will also get to know how we can create and clone a repository in local.

How to create repository in BitBucket:


If you don’t have account in BitBucket.Org then you need to create a account in BitBucket. You can create account from the following link.

Share:

Support this blog-Buy me a coffee

Buy me a coffeeBuy me a coffee
Search This Blog
Subscribe to my blog

  

My Mvp Profile
Follow us on facebook
Blog Archive
Total Pageviews