Search This Blog

Friday, December 29, 2017

BAD_SYSTEM_CONFIG_INFO

The error "BAD_SYSTEM_CONFIG_INFO" comes on the blue screen while booting your windows system and does not allow you to start your system. This could be because you have set all cores(processors) from msconfig tool to speed up your system.

To resolve this issue please follow the below steps:-

  1. Restart your system and press F8 to choose the start option
  2. Choose Repair option
  3. Select keyboard language
  4. Provide Administration login details
  5. Select "Command Prompt" from the repair option
  6. Select keyboard language
  7. Exdecute below command lines in Command Prompt

    bcdedit/deletevalue {default} numproc
    bcdedit/deletevalue {default} truncatememory

  8. Now Close Command promt window
  9. and Restart your machine

Saturday, December 16, 2017

The URL 'http://localhost/xxx' for Web project 'xxx' is configured to use IIS Express as the web server but the URL is currently configured on the local IIS web server. To open this project, you must use IIS Manager to remove the bindings using this URL from the local IIS web server



When you face the following error while loading your web project, please set the value of "UseIISExpress" to "false" in both file ".csproj" and ".csproj.user". After doing this setting reload your project and it will get loaded successfully.

ERROR : The URL 'http://localhost/xxx' for Web project 'xxx' is configured to use IIS Express as the web server but the URL is currently configured on the local IIS web server. To open this project, you must use IIS Manager to remove the bindings using this URL from the local IIS web server.

Sunday, June 11, 2017

Design Pattern : What is unit of work pattern?

Unit of work pattern is the concept to provide single transaction of multiple works(like insert, update, delete and so on.. ) of an entity as well as of multiple entities which has to be done into database in single go. If any one of the activities get failed then non of the activities will get executed in database, in short entire transaction will be roll backed.

Unit of Work design pattern does two important things: first it maintains in-memory updates and second it sends these in-memory updates as one transaction to the database.

So to achieve the above goals it goes through two steps:

  • It maintains lists of business objects in-memory which have been changed (inserted, updated, or deleted) during a transaction.
  • Once the transaction is completed, all these updates are sent as one big unit of work to be persisted physically in a database in one go.

See the below flow of transaction without unit of work and with unit of work

How to implement unit of work pattern in C#

The way to implement this pattern is as :

  1. Define an interface for repository to declare database operation.[Note: I will recommend a generic interface ]
  2. Create a class and implement repository interface.
  3. Create a class for unit of work.
  4. Access and implement unit of work in business logic
Step 1: Define Interface

create a interface to define database operations.

Step 2: Create Repository class

Implement operations defined in above IRepository interface. And create constructor to accept dbContext as parameter.

Step 3: Create Unit of Work class

Unit of work class has the responsibility to provide instance of dbContext to repository(shown as below).

Unit of work class has the three activities

  1. Create instance of dbContext
  2. Create instance of repositories against this single instance of dbContext
  3. Save the changes of dbContext into database(changes could be of one or more repositories)

Step 4: Access and implement unit of work in business logic

In below order class, instance of unit of work class is created to handle all type of communication with database. Here in AddOrder method two instances are created on for order and second for customer details. And both entity is saved into database as a single work unit.

Sunday, May 28, 2017

Design Pattern : What is repository pattern?

Repository Pattern separates the data access logic and maps it to the entities in the business logic. It works with the domain entities and performs data access logic. In the Repository pattern, the domain entities, the data access logic and the business logic talk to each other using interfaces. It hides the details of data access from the business logic. In other words, business logic can access the data object without having knowledge of the underlying data access architecture. For example, in the Repository pattern, business logic is not aware whether the application is using LINQ to SQL or ADO.NET Entity Model ORM. In the future, underlying data sources or architecture can be changed without affecting the business logic.

There are various advantages of the Repository Pattern including:

  • Business logic can be tested without need for an external source
  • Database access logic can be tested separately
  • Database access logic will hide the data access implementation details to the business logic(will create an abstraction between data access logic and business logic)
  • Business logic will not get impacted from the any changes happened in data access logic
  • No duplication of code
  • Caching strategy for the datasource can be centralized
  • Domain driven development is easier
  • Centralizing the data access logic, so code maintainability is easier

Repository acts as a mediator between business logic and data source(database).

How to Implement Repository pattern in C#

The way to implement repository pattern in any application is as:
  1. Define an interface for the repository.The interface declares the database operations.
  2. Create a class which implements the above interface and provides the implementation for the interface methods
  3. Access the repository from the business layer through the interface.

Step 1 : Define interface

Its highly recommended that an architecture must create a generic repository interface only.

Step 2 : Create Repository

Implement the database operation defined in step 1(IRepository)

In above code EntityBase is a base class for all entities which has an ID property of type Int.

Step 2 : Access repository from business logic

To access repository from business logic, create an instance of repository in business logic and use it as per requirement.

Monday, May 22, 2017

Javascript: How to encode and decode HTML using javascript?

Using below jquery code you can encode HTML

function htmlEncode(value){
  //create a in-memory div, set it's inner text(which jQuery automatically encodes)
  //then grab the encoded contents back out.  The div never exists on the page.
  return $('<div/>').text(value).html();
}

function htmlDecode(value){
  return $('<div/>').html(value).text();
}

htmlEncode('<b>test</b>')
// result"&lt;b&gt;test&lt;/b&gt;"

Friday, February 10, 2017

HTML: Unicode Decimal code for Indian Rupee Sign

To display Indian currency symbol, ₹ , in your HTML page you can use one of below code
&#8377
or
&#x20B9