Friday 29 July 2016

Select Multiple Fields from List in Linq

var name= listObject
    .Select(e => new { e.EmployeeId, e.EmployeeName})
    .Distinct()
    .OrderByDescending(e => e.EmployeeName)
    .ToArray();

five pillars of AngularJS

There are basically five pillars of AngularJS:

  • Directives
  • Controllers
  • Scopes
  • Services
  • Dependency Injection

Wednesday 27 July 2016

add new column with default constraint in sql

ALTER TABLE Employee
 ADD IsDeleted bit NOT NULL
 CONSTRAINT   DF_Employee _IsDeleted  default 0

Thursday 7 July 2016

change default value in sql


DECLARE @ObjectName NVARCHAR(10)
DECLARE @table_name NVARCHAR(10)
SELECT @ObjectName = default_constraints.name, @table_name = tables.name
FROM
sys.all_columns
    INNER JOIN
sys.tables
    ON all_columns.object_id = tables.object_id
    INNER JOIN
sys.schemas
    ON tables.schema_id = schemas.schema_id
 INNER JOIN
sys.default_constraints
    ON all_columns.default_object_id = default_constraints.object_id
WHERE
schemas.name = 'dbo'
AND tables.name = 'EmpRole'
AND all_columns.name = 'IsVisible'
EXEC ('ALTER TABLE '+@table_name+' DROP CONSTRAINT ' + @ObjectName)
ALTER TABLE EmpRole  ADD CONSTRAINT DF_EmpRoleRole_IsVisible DEFAULT 1 FOR Visible;