Thursday, June 13, 2013

Technical Reviewer of a new book "Razor View Engine How-to"

Packt Publishing recently released a new book titled – Instant Razor View Engine authored by Abhimanyu Kumar Vatsa. I  have also attached with this process as a technical reviewer.

The main aspect of this book is to made easy for the developers to understand the use of razor view engine in MVC. I found this book very helpful for beginner because it shows differences between different scenario with code example. It also covers differences between view engine and razor view engine.

This book guide developer a step by step procedure to learn razor view engine quickly and effectively. For advanced developers it also covers the custom model binding,Razor helper extension method,declarative syntax etc.

Friday, November 16, 2012

Observer Design Pattern using Delegates/events

Today I want to discuss with you how to implement Observer design pattern using delegate and event in /c#.

Observer Pattern

The observer pattern is a software design pattern in which an object, called the subject, maintains a list of its dependents, called observers, and notifies them automatically of any state changes, usually by calling one of their methods. It is mainly used to implement distributed event handling systems. The Observer pattern is also a key part in the familiar Model View Controller (MVC) architectural pattern.(wikipedia).

UML class diagram of Observer pattern(wikipedia)

The Observer Pattern describes the dependence relationship between one object (observable) to many objects (observers). It's also called Model/View, Dependents, or Distributor/Listener pattern.This article introduces an implementation when we can use the Observer pattern to keep all observer objects updated after things have changed.

Case project

In this case, patient is an ObservableObject that needs to send out the notification when the hospital updates his/her physical status. The hospital will determine who will be notified when the patient status is updated.

Thursday, November 15, 2012

A Custom Attribute based approach to write summary on business object

Last day, I have got a mail from a junior developer he needs some help about custom attributes. He has no previous experience about it. I have delivered his some speech or send some link for study. Today I have made an example for him, so that he can understand its usage very easily. Now this also share with you it may also help other friends.

using System;

Tuesday, October 9, 2012

MSSQL SERVER 2008 – IntelliSense Does Not Work

Last few months ago I have upgraded Visual Studio 2010 ultimate with service pack 1. But unfortunately my SQL Server Management Studio(SSMS) 2008 intellisense not working. After searching I got that it is a common problem. Please have visit here.

To fix it just install SQL Server 2008 r2 SP1. You can download it from here.

If it is not working please check the following issues it may solve your problem.

  • Verify that the T-SQL Editor does not launch in SQLCMD mode Under Tools->Options->Query Execution->SQL Server->General, make sure “By default, open new queries in SQLCMD mode” is unchecked.

Thursday, September 27, 2012

“The ‘VSTS for Database Professionals Sql Server Data-tier Application’ package did not load correctly”

After long time, I have got some relax from work pressures. I have got lots of mail about several issues. I had tried to give them hot fix with in a very short time. Sorry to everyone for my late response.

Today, when I am setting my new laptop I have faced a problem in VS 2010. Just run the VS2010 and got the error,
The ‘VSTS for Database Professionals Sql Server Data-tier Application’ package did not load correctly.
I don't understand why this is happening?

Potential cause:
This problem may occur due to install SQL Server Express 2008 with Visual Studio 2010 installation. When install SQL Server 2008 r2 on the same machine I had got an exception. So that I have uninstalled SQL Server Express 2008 from machine and then install SQL Server 2008 r2 but installation not completed successfully.

Solution 1:
I have got the solution from this link.
To fixed my problem I did the following tasks

Step-1: Run the Visual Studio 2010 Ultimate  disc
Step-2: Explore  \WCU\DAC folder from disc
Step-3: Now installed the three packages from the Visual Studio 2010 Ultimate disc and it fixed the problem right away for me.

Microsoft SQL Server 2008 R2 Data-Tier Application Framework with this command:

Microsoft SQL Server 2008 R2 Data-Tier Application Project:

Microsoft SQL Server 2008 R2 Transact-SQL Language Service:

If required you can re-install the Visual Studio 2010 Service pack 1.

Thursday, August 16, 2012

KeyValue pair/Dictionary with duplicate keys

Very recently for my development purpose I need to use Dictionary. And it works very nicely. But problem occurred when requirement changes and face a scenario that duplicate key's are needed to handle in Dictionary which is not possible. So I had written a custom class to handle this problem,please suggests me if there is any better idea.


public class KeyValuePair
public string Key { get; set; }
public int Value { get; set; }
public string HdValue { get; set; }

public KeyValuePair(string key, int value, string hdValue)
this.Key = key;
this.Value = value;
this.HdValue = hdValue;

Insert Data:
List<KeyValuePair> listKeyValuePair= new List<KeyValuePair>();
listKeyValuePair.Add(new KeyValuePair("TAX",2,"Income Tax"));
listKeyValuePair.Add(new KeyValuePair("TAX",4,"Vatlue added Tax"));
listKeyValuePair.Add(new KeyValuePair("PORT",9,"Vehicle Test"));

Sort Data:
List<KeyValuePair> listSorted = listKeyValuePair.OrderByDescending(x => x.key).ToList();

Filter Data:
var filteredData = listKeyValuePair.where(keyValue=> string.Compare(keyVaue.Key,"TAX")==0).ToList();
if(filteredData.Count > 0)
//Do something

Wednesday, August 15, 2012

Short circuit evaluations on && and || in JavaScript

Like many other languages Javascript’s && and || operators short-circuit evaluations,that is, for

&& if the first operand evaluates to false, the second operand is never evaluated because the result would always be false.
Similarly, for
|| if the result of the first operand is true, the second operand is never operated.

This means that in the following expression, x will never be compared to y.
true || x == y

This short-circuiting is great for performance, as it allows significant bits of calculations to be skipped. In addition to that, it lets you to write e.g. the following in one expression without getting an ‘object has no properties’ error:
oNode && oNode.firstChild

Be mindful though when using && with code that has side effects, e.g. say you have two objects with a hasError() method which return true or false depending on whether an error occurred and additionally output an error message:
x.hasError() && y.hasError()

Here, if x has an error, y will never be evaluated and thus the error message will never be shown.

For more details pls visits this and that.

Monday, July 2, 2012

Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

Very recently I got a mail from a junior guy he faced a problem every time when he installed the SQL server database on his workstation. But he failed to understand what is the main reason behind this. The problem was that after installing SQL server database his working web sites were throws exception like this...

System.Data.SqlClient.SqlException: Login failed for user 'NT AUTHORITY\NETWORK SERVICE'

The main reason behind this error occurs when you configured your web site with IIS. When any one tries to browse the site, IIS send the request to the SQL server with credentials. But unfortunately the credential do not have proper permission. So that it throws exception.

We can solve this problem in several ways....
First solution that resolved my problem was:

  1. Login to SQL server database via SQL Server Management Studio
  2. Go to the "Security" directory of desired database
  3. Right-click the Users directory
  4. Select "New User..."
  5. Add 'NT AUTHORITY\NETWORK SERVICE' as a new user
  6. In the Data Role Membership area, select db_owner
  7. Click OK