Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var hht = from x in db.HandheldAssets
- join a in db.HandheldDevInfos on x.AssetID equals a.DevName into DevInfo
- from aa in DevInfo.DefaultIfEmpty()
- select new
- {
- AssetID = x.AssetID,
- Status = xx.Online
- };
- select new {
- AssetID = x.AssetID,
- Status = aa == null ? (bool?)null : aa.Online; // a Nullable<bool>
- }
- select new {
- AssetID = x.AssetID,
- Status = aa == null ? false : aa.Online;
- }
- using(var ctx = new DataClasses1DataContext())
- {
- ctx.Log = Console.Out;
- var qry = from boss in ctx.Employees
- join grunt in ctx.Employees
- on boss.EmployeeID equals grunt.ReportsTo into tree
- from tmp in tree.DefaultIfEmpty()
- select new
- {
- ID = boss.EmployeeID,
- Name = tmp == null ? "" : tmp.FirstName
- };
- foreach(var row in qry)
- {
- Console.WriteLine("{0}: {1}", row.ID, row.Name);
- }
- }
- SELECT [t0].[EmployeeID] AS [ID],
- (CASE
- WHEN [t2].[test] IS NULL THEN CONVERT(NVarChar(10),@p0)
- ELSE [t2].[FirstName]
- END) AS [Name]
- FROM [dbo].[Employees] AS [t0]
- LEFT OUTER JOIN (
- SELECT 1 AS [test], [t1].[FirstName], [t1].[ReportsTo]
- FROM [dbo].[Employees] AS [t1]
- ) AS [t2] ON ([t0].[EmployeeID]) = [t2].[ReportsTo]
- -- @p0: Input NVarChar (Size = 0; Prec = 0; Scale = 0) []
- -- Context: SqlProvider(Sql2008) Model: AttributedMetaModel Build: 3.5.30729.1
- var hht = from x in db.HandheldAssets
- join a in db.HandheldDevInfos on x.AssetID equals a.DevName into DevInfo
- from aa in DevInfo.DefaultIfEmpty()
- select new
- {
- AssetID = x.AssetID,
- Status = xx.Online ?? false
- };
- MySum = MyTable.Where(x => x.SomeCondtion).Sum(x => x.AnIntegerValue);
- MySum = MyTable.Where(x => x.SomeCondtion).Sum(x => (int?) x.AnIntegerValue);
Add Comment
Please, Sign In to add comment