from c in Customers
join o in Orders on new {c.CompanyID, c.CustomerID} equals new {o.CompanyID, o.CustomerID}
Postgresql:
from Customers as c join Orders as o on (c.CompanyID,c.CustomerID) = (o.CompanyID,o.CustomerID)
"Simplicity can't be bought later, it must be earned from the start" -- DB
from c in Customers
join o in Orders on new {c.CompanyID, c.CustomerID} equals new {o.CompanyID, o.CustomerID}
from Customers as c join Orders as o on (c.CompanyID,c.CustomerID) = (o.CompanyID,o.CustomerID)
public class Flight
{
[DisplayWidth(200)]
[FinderController(UseFinder=typeof(CountryFinder), SelectedID="SelectedCountryCode")]
public string CountryCode { get; set; }
[DisplayWidth(200)]
[Color(Color.Blue)]
[FinderController(UseFinder=typeof(CityFinder), SelectedID="SelectedCityID", CascadingField="CountryCode")]
public int CityID { get; set; }
[DisplayWidth(100)]
[Spinner(From=1,To=30)]
public int StayDuration { get; set; }
}
public class Flight
{
public int CountryID { get; set; }
public int CityID { get; set; }
public int StayDuration { get; set; }
}
[FinderController(UseFinder=typeof(CityFinder), SelectedID="SelectedCityID", CascadingField="CountryCode")]
public int CityID { get; set; }
public class Flight
{
public int CountryCode { get; set; }
public int CityID { get; set; }
public int StayDuration { get; set; }
}
public class FlightInput : InputMap<Flight>
{
public FlightInput ()
{
Input(x => x.CountryCode) // Use C# 3's Expression
.DisplayWidth(200)
.Color(KnownColor.Blue)
.UseFinder<CountryFinder>().SelectedID(x => x.SelectedCountryCode);
Input(x => x.CityID)
.DisplayWidth(200)
.Color(KnownColor.Blue)
.UseFinder<CityFinder>().SelectedID(x => x.SelectedCityID).CascadingField(x => x.CountryCode);
Input(x => x.StayDuration)
.DisplayWidth(100).Color(KnownColor.Green)
.UseSpinner(1,10);
}
}
public ActionResult GetSoap()
{
return Json(new Soap { Name = "Tide", Feature = "With Calamansi" } );
}
public JsonResult GetSoap()
{
return Json(new Soap { Name = "Tide", Feature = "With Calamansi" } );
}
public object GetSoap()
{
return Json(new Soap { Name = "Tide", Feature = "With Calamansi" } );
}
[Test]
public void SomeTest()
{
// unnecessary casting
JsonResult r = (JsonResult) GetSoap();
Soap s = (Soap)r.Model;
}
[Test]
public void SomeTest()
{
JsonResult r = GetSoap();
Soap s = (Soap)r.Model;
}
using System;
namespace Craft
{
public delegate string Greeter(string s);
public class HeyAttribute : Attribute
{
public Greeter GreetAction { get; set; }
}
// Strongly-typed mechanism on attribute is no joy in C#, it's not
// possible. C# language designers reduces the attributes "complexity" :
// http://stackoverflow.com/questions/294216/why-does-c-sharp-forbid-generic-attribute-types
[Hey(GreetAction = Mate.Yo)] // This will not compile, despite the simplicity
public class Test
{
}
public class Mate
{
public static string Yo(string s)
{
return "Hello " + s;
}
}
class Program
{
static void Main(string[] args)
{
}
}
}
static void TestBanker()
{
Console.WriteLine(Math.Round(0.5)); // 0
Console.WriteLine(Math.Round(1.5)); // 2
Console.WriteLine(Math.Round(2.5)); // 2
Console.WriteLine(Math.Round(3.5)); // 4
Console.WriteLine(Math.Round(4.5)); // 4
Console.WriteLine(Math.Round(5.5)); // 6
Console.WriteLine(Math.Round(6.5)); // 6
Console.WriteLine(Math.Round(7.5)); // 8
Console.WriteLine(Math.Round(8.5)); // 8
Console.WriteLine(Math.Round(9.5)); // 10
}
static void TestCommon()
{
Console.WriteLine(Math.Round(0.5, MidpointRounding.AwayFromZero)); // 1
Console.WriteLine(Math.Round(1.5, MidpointRounding.AwayFromZero)); // 2
Console.WriteLine(Math.Round(2.5, MidpointRounding.AwayFromZero)); // 3
Console.WriteLine(Math.Round(3.5, MidpointRounding.AwayFromZero)); // 4
Console.WriteLine(Math.Round(4.5, MidpointRounding.AwayFromZero)); // 5
Console.WriteLine(Math.Round(5.5, MidpointRounding.AwayFromZero)); // 6
Console.WriteLine(Math.Round(6.5, MidpointRounding.AwayFromZero)); // 7
Console.WriteLine(Math.Round(7.5, MidpointRounding.AwayFromZero)); // 8
Console.WriteLine(Math.Round(8.5, MidpointRounding.AwayFromZero)); // 9
Console.WriteLine(Math.Round(9.5, MidpointRounding.AwayFromZero)); // 10
}
non-increasing increasing
unique incrementing + clustered composite primary key 23 19
clustered incrementing primary key + unique composite 20 19
non-increasing increasing
unique incrementing + clustered composite primary key 56 46
clustered incrementing primary key + unique composite 46 46
use master;
go
-- drop database testC;
-- go
create database testC;
go
use testC;
create table tbl
(
i int not null identity(1,1) unique,
a int not null,
b int not null,
x varchar(2000) not null,
constraint pk_tbl primary key clustered(a,b)
);
set nocount on;
declare @i int = 0;
while @i < 8 begin
declare @j int = 0;
while @j < 2000 begin
insert into tbl(a,b, x) values(@j,@i, replicate('x',2000));
set @j = @j + 1;
end;
set @i = @i + 1;
end;
set nocount off;
-- 23 seconds. 56 MB
use master;
go
-- drop database testD;
-- go
create database testD;
go
use testD;
create table tbl
(
i int identity(1,1) primary key clustered,
a int not null,
b int not null,
x varchar(2000) not null,
constraint uk_tbl unique(a,b)
);
set nocount on;
declare @i int = 0;
while @i < 8 begin
declare @j int = 0;
while @j < 2000 begin
insert into tbl(a,b, x) values(@j,@i, replicate('x',2000));
set @j = @j + 1;
end;
set @i = @i + 1;
end;
set nocount off;
-- 20 seconds. 46 MB
use master
go
-- drop database testE;
-- go
create database testE;
go
use testE;
create table tbl
(
i int not null identity(1,1) unique,
a int not null,
b int not null,
x varchar(2000) not null,
constraint pk_tbl primary key clustered(a,b)
);
set nocount on;
declare @i int = 0;
while @i < 8 begin
declare @j int = 0;
while @j < 2000 begin
insert into tbl(a,b, x) values(@i,@j, replicate('x',2000));
set @j = @j + 1;
end;
set @i = @i + 1;
end;
set nocount off;
-- 19 seconds. 46 MB
use master
go
-- drop database testF;
-- go
create database testF;
go
use testF;
create table tbl
(
i int identity(1,1) primary key clustered,
a int not null,
b int not null,
x varchar(2000) not null,
constraint uk_tbl unique(a,b)
);
set nocount on;
declare @i int = 0;
while @i < 8 begin
declare @j int = 0;
while @j < 2000 begin
insert into tbl(a,b, x) values(@i,@j, replicate('x',2000));
set @j = @j + 1;
end;
set @i = @i + 1;
end;
set nocount off;
-- 19 seconds. 46 MB
CREATE procedure [dbo].[GetTheSalesOfSalesPerson] as begin select h.SalesPersonID, p.LastName, p.MiddleName, p.FirstName, p.EmailPromotion , h.SalesOrderNumber , h.OrderDate , s.Name as CustomerName from Person.Person p join Sales.SalesOrderHeader h on h.SalesPersonID = p.BusinessEntityID join Sales.Customer c on c.CustomerID = h.CustomerID join Sales.Store s on s.BusinessEntityID = c.StoreID where h.OrderDate >= convert(date, '2008-01-01') order by h.SalesPersonID; end;
![]() |
| 1 |
![]() |
| 2 |
![]() |
| 3 |
![]() |
| 4 |
![]() |
| 5 |
![]() |
| 6 |
![]() |
| 7 |
![]() |
| 8 |
![]() |
| 9 |
![]() |
| 10 |
![]() |
| 11 |
![]() |
| 12 |
![]() |
| 13 |
![]() |
| 14 |
![]() |
| 15 |
![]() |
| 16 |
![]() |
| 17 |
![]() |
| 18 |
![]() |
| 19 |
![]() |
| 20 |
![]() |
| 21 |
![]() |
| 22 |
![]() |
| 23 |
![]() |
| 24. We got to format the grouped column if it is a date |
![]() |
| 25. To do that, we set its Text Box Properties |
![]() |
| 26. Go to Number tab, then choose Custom |
![]() |
| 27. Then put the above expression |
![]() |
| 28. Then conditionally hide the column if the grouping is on that column |
![]() |
| 29 |
![]() |
| 30 |
![]() |
| 31 |
![]() |
| 32 |
![]() |
| 33 |
![]() |
| 34. Hide the Order Date conditionally too (if the grouping is on Order Date) |
![]()
| ||
![]() |
| 37 |
![]() |
| 38. Good |
![]() |
| 40. We must set the order based on the grouping column |
![]() |
| 41. The default was CustomerName |
![]() |
| 42. Click the fx expression button. The above will appear |
![]() |
| 43. Then change the expression with the above simple expression. As we cannot do conditional order (ascending vs descending), we will just put the descending Order Date on a separate sorting option |
![]() |
| 44. Your sort by should appear as Expr |
![]() |
| 45. Then add another column |
![]() |
| 46. The expression that shall appear on another order expression |
![]() |
| 47 |
![]() |
| 48 |
![]() |
| 49. Change the Then By's sorting to descending |
![]() |
| 50. The sorting is correct now |