Posts

Showing posts from January, 2018

Distinct objects & distinct based on a specific propertie (in this case Mobile and Fax) by LINQ

// distinct objects List<objects> listObjects = ( from obj in db.Objects select obj).Distinct().ToList(); // distinct based on a specific propertie (in this case Mobile and Fax) List<Objects> listObjects = ( from obj in db.Objects select obj).GroupBy(n = > new {n.Mobile, n.Fax}) .Select(g = > g.FirstOrDefault()) .ToList();

SQL Store Procedure To Class Wrapper

DECLARE @sql NVARCHAR(MAX) = N'EXEC ShopMenu_GermanClub.dbo.SP_ReportRM_PO_Challan ww,admin,Y;'; --SELECT name, system_type_name --    FROM sys.dm_exec_describe_first_result_set(@sql, NULL, 1) AS col declare @TableName sysname = 'SP_ReportRM_PO_Challan' declare @Result varchar(max) = 'public class ' + @TableName + ' {' select @Result = @Result + '     public ' + ColumnType + NullableSign + ' ' + ColumnName + ' { get; set; } ' from (     select          replace(col.name, ' ', '_') ColumnName,                  case --col.system_type_name              WHEN (CHARINDEX('nvarchar',system_type_name)>0) then 'string'             when (system_type_name='bigint') then 'long'         ...