Sunday 30 April 2017

C# AutoMapper.Mapper does not contain definition for CreateMap

public ClientEntity GetById(int id)
          {
                 ClientEntity returnClientEntity = new ClientEntity();
                 try
                 {
                        using (var scope = new TransactionScope(TransactionScopeOption.Required, new TransactionOptions { IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted }))
                        {
                               using (DBContext context = new DBContext())
                               {

                                      //Get data based on  id                 
                                      var clientInfoDB = context.Clientinfoes.Where(s => s.ClientID == id).FirstOrDefault();

                                      if (clientInfoDB != null)
                                      {

                                             ////I tried below line first
                                             //returnClientEntity = clientInfoDB;
                                             //return clientInfoDB;// get error


                                             //Problem: clientInfoDB is DB object, but method is returning entity object which is not ClientEntity
                                             //So need mapping b/w DB and entity

                                             //Solution--start
                                             var config = new MapperConfiguration(cfg => {
                                                   cfg.CreateMap<Clientinfo, ClientEntity>();
                                             });

                                             IMapper mapper = config.CreateMapper();
//below line is mapping b/w DB and entity
                                             returnClientEntity = mapper.Map<Clientinfo, ClientEntity>(clientInfoDB);
                                             //end
                                      }
                                      else
                                      {
                                             return null;
                                      }
                               }
                        }
                 }
                 catch (Exception ex)
                 {

                 }
                 return returnClientEntity;

              }

Wednesday 26 April 2017

Wednesday 19 April 2017

HTTP Error 500.19 - Internal Server Error on IIS 10

Solution Steps:

Open control panel -->"program" -->
Click on turn windows features on/off -->locate” Internet Information services IIS” in the pop up window and expand its node
Expand the” World Wide Web Service” node
Expand “Application Development Features” node
check the check box of”ASP.NET”
Then click OK  button

radio

http://radio.garden/live

Friday 14 April 2017

Visual studio online create new team project

Open: https://www.visualstudio.com/team-services/
Click on free account
Enter your account details
Click on "create new account"
You will see all u r account: https://app.vsaex.visualstudio.com/me?mkt=en-US&campaign=o~msft~vscom~product-vsts-nav~menu
Click on any account
Ex: https://myaccountName.visualstudio.com/_projects



Click on New Project
Ex: Project Name: Demo
Version Control: TFS
Work Item process: Scrum
Click on "Create"
You will get below screen
https://myaccountName.visualstudio.com/Demo
Under "Members" Click on +
Enter outlook email id

Open Visual studio as administrator
Click  on Team
Select Connect Team foundation server:  : https://myaccountName.visualstudio.com

Click on Plug Icon under "Team Foundation" window
(if you have already connected to TFS, then click on  "Select Team projets...")
Select Right Team Foundation server
It will  load all Team Projects
Select "Demo"
Click on Connect
Double click on "Demo" from TFS window
You will see: Configure your workspace mappings to get started developing
Click on "Configure your workspace mappings to get started developing"

In your local first create a folder strcture ex: F:\tfs\Demo

Enter local folder path as: F:\tfs\Demo
Click on "Map&Get"

If you go to this path: F:\tfs\Demo
You will see "BuildProcessTemplates" folder

Under VS-->Team-->Manage Connections..-->Under Team explorer - connect
Click on Home icon
Click on “Source Control explorer”
Ex:

Right click after “BuildProcessTemplates”, select “new Folder” name it: Sourcecode

Go inside “Sourcecode” folder
Right click Create New folder name as “Dev”
Same way create: “QA”, “UAT”, “Prod”
Go to “Dev” folder

You will see all these folders in local also:
F:\tfs\Demo\Sourcecode\Dev

File "New Project"
Search for blank solution
Select Blank solution
Name it as: Demo
Location as: F:\tfs\Demo\Sourcecode\Dev

Check "Add to source control" check box
Ok
You will get new window to Add solution "Demo" to Source control
Select "Demo"
Click Ok
By this time, in VS, you will see all blank solution with name as "Demo"
From VS
Right click on "Demo" solution
Click on "Check in"
Enter comments
Check In


In VS
File "New Project"
Select "Class Library"
name it: Demo.Entity
Location path: F:\tfs\Demo\Demo
Check "Add to source control" check box
OK

Click on Solution
Add new project
Select "Class Library"
name it "Demo.DAL"
Location path: F:\tfs\Demo\Sourcecode\Dev\Demo
Check "Add to source control" check box
OK



Click on Solution
Add new project
Select "Class Library"
name it "Demo.Services"
Location path: F:\tfs\Demo\Sourcecode\Dev\Demo
Check "Add to source control" check box
OK


Click on Solution
Add new project
Select "Web"-->ASP.NET Web Application
name it "Demo.API"
Location path: F:\tfs\Demo\Sourcecode\Dev\Demo
Check "Add to source control" check box
OK
In the new window select "Web API"

Check "Web Forms" check box

Ok


After Dev completion, move all the file to "QA"

Wednesday 12 April 2017

SQL Create table with primary key and UNIQUE key

SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[MyTable](
 [SNo] [int] NOT NULL,
 [UserName] [int] NOT NULL,
 [Password] [nvarchar](50) NULL,
 CONSTRAINT [UQ_MyTable_UserName] UNIQUE NONCLUSTERED
(
 [UserName] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

In the project column of the "Error List" window, I see DNX Core 5.0.

The type or namespace '[someclass]' could not be found.
In the project column of the "Error List" window, I see DNX Core 5.0.


solution:

In case some people are still struggling with this, you can dereference the DNX Core 5.0 by removing it from your framework references in the project.json file.

The section

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },
Should become

  "frameworks": {
    "dnx451": { }
  },


now i got bellow error:
Error: Please run “dnu restore” to generate a new lock file

solution:
Go to the project where you are getting above error
Right click on "References" then select "Restore Packages"