日期:2014-05-20 浏览次数:20823 次
var query = from ep in db.Enterprise select new { Validity = ep.SecondHouse.FirstOrDefault().Validity==null?new DateTime(1900,01,01):DateTime.Parse(ep.SecondHouse.FirstOrDefault().Validity) };
SELECT (CASE WHEN NOT (EXISTS( SELECT TOP (1) NULL AS [EMPTY] FROM [dbo].[SecondHouse] AS [t2] WHERE [t2].[EntId] = [t0].[Id] )) THEN 1 WHEN NOT NOT (EXISTS( SELECT TOP (1) NULL AS [EMPTY] FROM [dbo].[SecondHouse] AS [t2] WHERE [t2].[EntId] = [t0].[Id] )) THEN 0 ELSE NULL END) AS [value], ( SELECT [t4].[Validity] FROM ( SELECT TOP (1) [t3].[Validity] FROM [dbo].[SecondHouse] AS [t3] WHERE [t3].[EntId] = [t0].[Id] ) AS [t4] ) AS [s] FROM [dbo].[Enterprise] AS [t0]