Posts

Showing posts from July, 2013

NULL plus anything sql

In SQL NULL plus anything equals NULL Ex: SELECT MyColumn + 100 In the above case if mycolumn is null then the result is NULL Alternate solutions SELECT          CASE WHEN MyColumn IS NULL                      THEN 0                ELSE MyColumn END  FROM MyTable SELECT ISNULL(mycolumn, 0)  + 100 FROM MyTable

Where can I find IIS in Windows 7?

Before that you have to enable the IIS for windows by start Control panel programs Turn windows feature on / off Check the IIS services (4th and 5th checkbox) ok restart the system

Create xml from database using LINQ

Image
Create XML from Database Suppose we have below table in database. Now I want to make xml of all the products which have stock greater than 0. Here I am using  LINQ Pad  to query data from the database. It is a great tool to query data from database using LINQ to SQL, LINQ to XML, LINQ to Entity Framework. CREATE TABLE Product ( ProductID int IDENTITY ( 1 , 1 ) NOT NULL , ProductName varchar ( 50 ) NOT NULL , Price float NOT NULL , Stock int NOT NULL ) GO INSERT INTO Product ( ProductName , Price , Stock ) VALUES ( 'P001' , 12.12 , 100 ) INSERT INTO Product ( ProductName , Price , Stock ) VALUES ( 'P002' , 102.12 , 200 ) INSERT INTO Product ( ProductName , Price , Stock ) VALUES ( 'P003' , 104.12 , 500 ) INSERT INTO Product ( ProductName , Price , Stock ) VALUES ( 'P004' , 108.12 , 100 ) INSERT INTO Product ( ProductName , Price , Stock ) VALUES ( 'P005' , 72.12 , 10 ) INSERT INTO Product ( ProductName , ...

Difference between Var and IEnumerable

Var VS IEnumerable In previous article I explain the difference between  IEnumerable and IQuerable ,  IEnumerable and IList . In this article I expose the difference between Var and IEnumerable. IEnumerable is an interface that can move forward only over a collection, it can’t move backward and between the items. Var is used to declare implicitly typed local variable means it tells the compiler to figure out the type of the variable at compilation time. A var variable must be initialized at the time of declaration. Both have its own importance to query data and data manipulation. Var Type Since  Var  is anonymous types, hence use it whenever you don't know the type of output or it is anonymous. Suppose you are joining two tables and retrieving data from both the tables then the result will be an Anonymous type. var q =( from e in tblEmployee join d in tblDept on e . DeptID equals d . DeptID select new { e . EmpID , e . FirstName , d . Dept...

Avoid ads in Youtube

https://adblockplus.org/en/chrome