Group by Day – Örnekleri ile
Grouping By Day Of month: In order to group the data by day you can use sql server in built DAY() funtion. Grouping By Day Of week: For this you can use DATEPART(weekday,[date column]) Grouping By week: For this you can use DATEPART(week,[date column]) Grouping By DAY of Year: For this you can use DATEPART(dayofyear,[date […]
Veritabanındaki Tablodan Class Üretmek (Generate Class from database table)
declare @TableName sysname = ‘TableName’ declare @Result varchar(max) = ‘public class ‘ + @TableName + ‘ {‘ select @Result = @Result + ‘ public ‘ + ColumnType + NullableSign + ‘ ‘ + ColumnName + ‘ { get; set; } ‘ from ( select replace(col.name, ‘ ‘, ‘_’) ColumnName, column_id ColumnId, case typ.name when ‘bigint’ […]
Tuple?
A tuple is a data structure that has a specific number and sequence of elements. A tuple allows you to combine multiple values of possibly different types into a single object without having to create a custom class. This can be useful if you want to write a method that for example returns three related […]
DateTime format
class Program { public static void Main(string[] args) { DateTime thisDate = DateTime.Now; //Standard Time Formatting //Pattern 1: dd/MM/yyyy Console.WriteLine(“Pattern 1: Today is in dd/MM/yyyy format :” + thisDate.ToString(“dd/MM/yyyy”));//18/09/2016 //Pattern 2: dd-MM-yyyy Console.WriteLine(“Pattern 2: Today is in dd-MM-yyyy format :” + thisDate.ToString(“dd-MM-yyyy”));//18-09-2016 //Pattern 3: yyyy-MM-dd Console.WriteLine(“Pattern 3: Today is in yyyy-MM-dd format :” + thisDate.ToString(“yyyy-MM-dd”));//2016-09-18 […]
C# – String format for Double
using System; public class Program { public static void Main(string[] args) { // Pattern 1: just two decimal places Console.WriteLine(“**************************************”); Console.WriteLine(“Pattern 1: just two decimal places”); Console.WriteLine(“**************************************”); Console.WriteLine(String.Format(“{0:0.00}”, 123.4567)); // “123.46” Console.WriteLine(String.Format(“{0:0.00}”, 123.4)); // “123.40” Console.WriteLine(String.Format(“{0:0.00}”, 123.0)); // “123.00” //Pattern 2: max. two decimal places Console.WriteLine(“**************************************”); Console.WriteLine(“Pattern 2: max. two decimal places”); Console.WriteLine(“**************************************”); Console.WriteLine(String.Format(“{0:0.##}”, 123.4567)); […]
Truncate Table Foreign Key varken
DECLARE @TableName NVARCHAR(128)=’TabloAdi’ BEGIN TRAN DECLARE @NextId NUMERIC = CASE WHEN (IDENT_CURRENT(@TableName) = 1) THEN 1 ELSE 0 END DECLARE @Sql NVARCHAR(MAX) = ‘DELETE FROM [‘ + @TableName + ‘]’ EXECUTE sp_executesql @Sql IF (@@ERROR = 0) BEGIN DBCC CHECKIDENT (@TableName, RESEED, @NextId) COMMIT TRAN END ELSE BEGIN ROLLBACK END Kaynak: Eduardo Cuomo
String Join
string[] eleman = { “bir”, “iki”, “üç” }; string birlestir= string.Join(“;”, eleman); // birlestir = bir;iki;üç Kaynak: DotNetPerls
SELECT yapısı içinde Önceki ve Sonraki Kayıt
SELECT LAG(p.FirstName) OVER (ORDER BY p.BusinessEntityID) PreviousValue, p.FirstName, LEAD(p.FirstName) OVER (ORDER BY p.BusinessEntityID) NextValue FROM Person.Person p Kaynak: sqlauthority.com
Çok Boyutlu Class Dizilerde Döngüler
MyClass[][,][,] abc = new MyClass[10][,][,]; for (int i = 0; i < abc.Length; i++) { abc[i] = new MyClass[20, 30][,]; for (int j = 0; j < abc[i].GetLength(0); j++) { for (int k = 0; k < abc[i].GetLength(1); k++) { abc[i][j, k] = new MyClass[40, 50]; } } } Kaynak: StackOverFlow
İki DataTable Karşılaştırması
var qry1 = datatable1.AsEnumerable().Select(a => new { MobileNo = a[“ID”].ToString() }); var qry2 = datatable2.AsEnumerable().Select(b => new { MobileNo = b[“ID”].ToString() }); var exceptAB = qry1.Except(qry2); DataTable dtMisMatch = (from a in datatable1.AsEnumerable() join ab in exceptAB on a[“ID”].ToString() equals ab.MobileNo select a).CopyToDataTable(); Kaynak: CodeProject
