我在asp.net mvc控制器的操作方法中有以下代码: -
racks = repository.AllFindRacks_j(withOutSpace).OrderBy(a => a.DataCenter.Name)
.ToPagedList(page, pagesize);
将调用以下2个存储库方法: -
public IQueryable<ITRack> AllFindRacks_j(string q, bool forautocomplete = false)
{return from rack in ITRacksCore().Where(a => a.Technology.Tag.ToUpper().StartsWith(q.ToUpper()) || (string.IsNullOrEmpty(q)))
select rack;}
public IQueryable<ITRack> ITRacksCore()
{
return IT.ITRacks.Include(rack => rack.DataCenter).Include(rack => rack.Zone).Include(rack => rack.ITFirewalls).Include(rack => rack.ITRouters).Include(rack => rack.ITServers).Include(rack => rack.ITStorageDevices).Include(rack => rack.ITSwitches).Include(rack => rack.Technology.TechnologyType);
}
我只是期望结果将由Datacenter.Name订购,但我得到的是数据中心名称没有排序记录,我无法确定返回结果的模式。虽然我使用相同的方法根据其他列对记录进行排序,但orderby运行良好。任何人都可以建议可能是什么问题? 的修改 这是在进行排序后生成的sql语句: -
exec sp_executesql N'SELECT
//code goes here
[UnionAll2].[C77] AS [C77],
[UnionAll2].[C78] AS [C78],
[UnionAll2].[C79] AS [C79]
FROM (SELECT
[UnionAll1].[C1] AS [C1],
[UnionAll1].[Name] AS [C2],
[UnionAll1].[TechnologyID] AS [C3],
[UnionAll1].[ITRackID] AS [C4],
[UnionAll1].[ID] AS [C5],
//code goes here
[UnionAll1].[C38] AS [C78],
[UnionAll1].[C39] AS [C79]
FROM (SELECT
CASE WHEN ([Extent6].[FirewallID] IS NULL) THEN CAST(NULL AS int) ELSE 1 END AS [C1],
[Limit1].[Name] AS [Name],
//code goes here,
CAST(NULL AS bigint) AS [C38],
CAST(NULL AS varbinary(1)) AS [C39]
FROM (SELECT TOP (15) [Project1].[ITRackID] AS [ITRackID], [Project1].[DataCenterID] AS [DataCenterID], [Project1].[ZoneID] AS [ZoneID], [Project1].[timestamp] AS [timestamp], [Project1].[IT360SiteID] AS [IT360SiteID], [Project1].[TechnologyID] AS [TechnologyID], [Project1].[Tag] AS [Tag], [Project1].[IsDeleted] AS [IsDeleted], [Project1].[timestamp1] AS [timestamp1], [Project1].[TypeID] AS [TypeID], [Project1].[StartDate] AS [StartDate], [Project1].[IT360ID] AS [IT360ID], [Project1].[IsCompleted] AS [IsCompleted], [Project1].[PartialTag] AS [PartialTag], [Project1].[ID] AS [ID], [Project1].[Name] AS [Name], [Project1].[timestamp2] AS [timestamp2], [Project1].[ZoneID1] AS [ZoneID1], [Project1].[Name1] AS [Name1], [Project1].[DataCenterID1] AS [DataCenterID1], [Project1].[AssetTypeID] AS [AssetTypeID], [Project1].[Name2] AS [Name2], [Project1].[IncludedInSearch] AS [IncludedInSearch]
FROM ( SELECT [Project1].[ITRackID] AS [ITRackID], [Project1].[DataCenterID] AS [DataCenterID], [Project1].[ZoneID] AS [ZoneID], [Project1].[timestamp] AS [timestamp], [Project1].[IT360SiteID] AS [IT360SiteID], [Project1].[TechnologyID] AS [TechnologyID], [Project1].[Tag] AS [Tag], [Project1].[IsDeleted] AS [IsDeleted], [Project1].[timestamp1] AS [timestamp1], [Project1].[TypeID] AS [TypeID], [Project1].[StartDate] AS [StartDate], [Project1].[IT360ID] AS [IT360ID], [Project1].[IsCompleted] AS [IsCompleted], [Project1].[PartialTag] AS [PartialTag], [Project1].[ID] AS [ID], [Project1].[Name] AS [Name], [Project1].[timestamp2] AS [timestamp2], [Project1].[ZoneID1] AS [ZoneID1], [Project1].[Name1] AS [Name1], [Project1].[DataCenterID1] AS [DataCenterID1], [Project1].[AssetTypeID] AS [AssetTypeID], [Project1].[Name2] AS [Name2], [Project1].[IncludedInSearch] AS [IncludedInSearch], row_number() OVER (ORDER BY [Project1].[Name] ASC) AS [row_number]
FROM ( SELECT
[Extent1].[ITRackID] AS [ITRackID],
[Extent1].[DataCenterID] AS [DataCenterID],
[Extent1].[ZoneID] AS [ZoneID],
[Extent1].[timestamp] AS [timestamp],
[Extent1].[IT360SiteID] AS [IT360SiteID],
[Extent2].[TechnologyID] AS [TechnologyID],
[Extent2].[Tag] AS [Tag],
[Extent2].[IsDeleted] AS [IsDeleted],
[Extent2].[timestamp] AS [timestamp1],
[Extent2].[TypeID] AS [TypeID],
[Extent2].[StartDate] AS [StartDate],
[Extent2].[IT360ID] AS [IT360ID],
[Extent2].[IsCompleted] AS [IsCompleted],
[Extent2].[PartialTag] AS [PartialTag],
[Extent3].[ID] AS [ID],
[Extent3].[Name] AS [Name],
[Extent3].[timestamp] AS [timestamp2],
[Extent4].[ZoneID] AS [ZoneID1],
[Extent4].[Name] AS [Name1],
[Extent4].[DataCenterID] AS [DataCenterID1],
[Extent5].[AssetTypeID] AS [AssetTypeID],
[Extent5].[Name] AS [Name2],
[Extent5].[IncludedInSearch] AS [IncludedInSearch]
FROM [dbo].[ITRacks] AS [Extent1]
INNER JOIN [dbo].[Technology] AS [Extent2] ON [Extent1].[ITRackID] = [Extent2].[TechnologyID]
INNER JOIN [dbo].[DataCenter] AS [Extent3] ON [Extent1].[DataCenterID] = [Extent3].[ID]
INNER JOIN [dbo].[Zones] AS [Extent4] ON [Extent1].[ZoneID] = [Extent4].[ZoneID]
LEFT OUTER JOIN [dbo].[TechnologyTypes] AS [Extent5] ON [Extent2].[TypeID] = [Extent5].[AssetTypeID]
WHERE (@p__linq__0 IS NULL) OR (( CAST(LEN(@p__linq__0) AS int)) = 0) OR (( CAST(CHARINDEX(UPPER(@p__linq__1), UPPER([Extent2].[Tag])) AS int)) = 1)
) AS [Project1]
) AS [Project1]
WHERE [Project1].[row_number] > 0
ORDER BY [Project1].[Name] ASC ) AS [Limit1]
LEFT OUTER JOIN [dbo].[ITFirewalls] AS [Extent6] ON [Limit1].[ITRackID] = [Extent6].[RackID]
UNION ALL
SELECT
2 AS [C1],
[Limit2].[Name] AS [Name],
[Limit2].[TechnologyID] AS [TechnologyID],
[Limit2].[ITRackID] AS [ITRackID],
[Limit2].[ID] AS [ID],
[Limit2].[ITRackID] AS [ITRackID1],
[Limit2].[TechnologyID] AS [TechnologyID1],
[Limit2].[ITRackID] AS [ITRackID2],
[Limit2].[ITRackID] AS [ITRackID3],
[Limit2].[ITRackID] AS [ITRackID4],
[Limit2].[DataCenterID] AS [DataCenterID],
[Limit2].[ZoneID] AS [ZoneID],
[Limit2].[timestamp] AS [timestamp],
[Limit2].[IT360SiteID] AS [IT360SiteID],
[Limit2].[ID] AS [ID1],
[Limit2].[Name] AS [Name1],
[Limit2].[timestamp2] AS [timestamp1],
[Limit2].[ZoneID1] AS [ZoneID1],
[Limit2].[Name1] AS [Name2],
[Limit2].[DataCenterID1] AS [DataCenterID1],
[Limit2].[ITRackID] AS [ITRackID5],
[Limit2].[TechnologyID] AS [TechnologyID2],
[Limit2].[Tag] AS [Tag],
[Limit2].[IsDeleted] AS [IsDeleted],
[Limit2].[timestamp1] AS [timestamp2],
[Limit2].[TypeID] AS [TypeID],
[Limit2].[StartDate] AS [StartDate],
[Limit2].[IT360ID] AS [IT360ID],
[Limit2].[IsCompleted] AS [IsCompleted],
[Limit2].[PartialTag] AS [PartialTag],
[Limit2].[AssetTypeID] AS [AssetTypeID],
[Limit2].[Name2] AS [Name3],
[Limit2].[IncludedInSearch] AS [IncludedInSearch],
CAST(NULL AS int) AS [C2],
CAST(NULL AS int) AS [C3],
CAST(NULL AS int) AS [C4],
CAST(NULL AS varchar(1)) AS [C5],
CAST(NULL AS varchar(1)) AS [C6],
CAST(NULL AS varbinary(1)) AS [C7],
CAST(NULL AS bigint) AS [C8],
CAST(NULL AS varchar(1)) AS [C9],
[Extent12].[RouterID] AS [RouterID],
[Extent12].[ModelID] AS [ModelID],
[Extent12].[RackID] AS [RackID],
[Extent12].[Description] AS [Description],
[Extent12].[ConsoleServerID] AS [ConsoleServerID],
[Extent12].[ConsoleServerIPIn] AS [ConsoleServerIPIn],
[Extent12].[ConsoleServerIPOut] AS [ConsoleServerIPOut],
[Extent12].[Spec] AS [Spec],
[Extent12].[timestamp] AS [timestamp3],
[Extent12].[IT360SiteID] AS [IT360SiteID1],
CAST(NULL AS int) AS [C10],
CAST(NULL AS int) AS [C11],
CAST(NULL AS varchar(1)) AS [C12],
CAST(NULL AS int) AS [C13],
CAST(NULL AS int) AS [C14],
CAST(NULL AS int) AS [C15],
CAST(NULL AS int) AS [C16],
CAST(NULL AS int) AS [C17],
CAST(NULL AS int) AS [C18],
CAST(NULL AS varchar(1)) AS [C19],
CAST(NULL AS varbinary(1)) AS [C20],
CAST(NULL AS bigint) AS [C21],
CAST(NULL AS int) AS [C22],
CAST(NULL AS decimal(8,2)) AS [C23],
CAST(NULL AS int) AS [C24],
CAST(NULL AS varchar(1)) AS [C25],
CAST(NULL AS varbinary(1)) AS [C26],
CAST(NULL AS bigint) AS [C27],
CAST(NULL AS int) AS [C28],
CAST(NULL AS int) AS [C29],
CAST(NULL AS varchar(1)) AS [C30],
CAST(NULL AS int) AS [C31],
CAST(NULL AS int) AS [C32],
CAST(NULL AS varchar(1)) AS [C33],
CAST(NULL AS varchar(1)) AS [C34],
CAST(NULL AS varchar(1)) AS [C35],
CAST(NULL AS bigint) AS [C36],
CAST(NULL AS varbinary(1)) AS [C37]
FROM (SELECT TOP (15) [Project3].[ITRackID] AS [ITRackID], [Project3].[DataCenterID] AS [DataCenterID], [Project3].[ZoneID] AS [ZoneID], [Project3].[timestamp] AS [timestamp], [Project3].[IT360SiteID] AS [IT360SiteID], [Project3].[TechnologyID] AS [TechnologyID], [Project3].[Tag] AS [Tag], [Project3].[IsDeleted] AS [IsDeleted], [Project3].[timestamp1] AS [timestamp1], [Project3].[TypeID] AS [TypeID], [Project3].[StartDate] AS [StartDate], [Project3].[IT360ID] AS [IT360ID], [Project3].[IsCompleted] AS [IsCompleted], [Project3].[PartialTag] AS [PartialTag], [Project3].[ID] AS [ID], [Project3].[Name] AS [Name], [Project3].[timestamp2] AS [timestamp2], [Project3].[ZoneID1] AS [ZoneID1], [Project3].[Name1] AS [Name1], [Project3].[DataCenterID1] AS [DataCenterID1], [Project3].[AssetTypeID] AS [AssetTypeID], [Project3].[Name2] AS [Name2], [Project3].[IncludedInSearch] AS [IncludedInSearch]
FROM ( SELECT [Project3].[ITRackID] AS [ITRackID], [Project3].[DataCenterID] AS [DataCenterID], [Project3].[ZoneID] AS [ZoneID], [Project3].[timestamp] AS [timestamp], [Project3].[IT360SiteID] AS [IT360SiteID], [Project3].[TechnologyID] AS [TechnologyID], [Project3].[Tag] AS [Tag], [Project3].[IsDeleted] AS [IsDeleted], [Project3].[timestamp1] AS [timestamp1], [Project3].[TypeID] AS [TypeID], [Project3].[StartDate] AS [StartDate], [Project3].[IT360ID] AS [IT360ID], [Project3].[IsCompleted] AS [IsCompleted], [Project3].[PartialTag] AS [PartialTag], [Project3].[ID] AS [ID], [Project3].[Name] AS [Name], [Project3].[timestamp2] AS [timestamp2], [Project3].[ZoneID1] AS [ZoneID1], [Project3].[Name1] AS [Name1], [Project3].[DataCenterID1] AS [DataCenterID1], [Project3].[AssetTypeID] AS [AssetTypeID], [Project3].[Name2] AS [Name2], [Project3].[IncludedInSearch] AS [IncludedInSearch], row_number() OVER (ORDER BY [Project3].[Name] ASC) AS [row_number]
FROM ( SELECT
[Extent7].[ITRackID] AS [ITRackID],
[Extent7].[DataCenterID] AS [DataCenterID],
[Extent7].[ZoneID] AS [ZoneID],
[Extent7].[timestamp] AS [timestamp],
[Extent7].[IT360SiteID] AS [IT360SiteID],
[Extent8].[TechnologyID] AS [TechnologyID],
[Extent8].[Tag] AS [Tag],
[Extent8].[IsDeleted] AS [IsDeleted],
[Extent8].[timestamp] AS [timestamp1],
[Extent8].[TypeID] AS [TypeID],
[Extent8].[StartDate] AS [StartDate],
[Extent8].[IT360ID] AS [IT360ID],
[Extent8].[IsCompleted] AS [IsCompleted],
[Extent8].[PartialTag] AS [PartialTag],
[Extent9].[ID] AS [ID],
//code goes here
CAST(NULL AS int) AS [C20],
CAST(NULL AS decimal(8,2)) AS [C21],
CAST(NULL AS int) AS [C22],
CAST(NULL AS varchar(1)) AS [C23],
CAST(NULL AS varbinary(1)) AS [C24],
CAST(NULL AS bigint) AS [C25],
CAST(NULL AS int) AS [C26],
CAST(NULL AS int) AS [C27],
CAST(NULL AS varchar(1)) AS [C28],
CAST(NULL AS int) AS [C29],
CAST(NULL AS int) AS [C30],
CAST(NULL AS varchar(1)) AS [C31],
CAST(NULL AS varchar(1)) AS [C32],
CAST(NULL AS varchar(1)) AS [C33],
CAST(NULL AS bigint) AS [C34],
CAST(NULL AS varbinary(1)) AS [C35]
FROM (SELECT TOP (15) [Project6].[ITRackID] AS [ITRackID], [Project6].[DataCenterID] AS [DataCenterID], [Project6].[ZoneID] AS [ZoneID], [Project6].[timestamp] AS [timestamp], [Project6].[IT360SiteID] AS [IT360SiteID], [Project6].[TechnologyID] AS [TechnologyID], [Project6].[Tag] AS [Tag], [Project6].[IsDeleted] AS [IsDeleted], [Project6].[timestamp1] AS [timestamp1], [Project6].[TypeID] AS [TypeID], [Project6].[StartDate] AS [StartDate], [Project6].[IT360ID] AS [IT360ID], [Project6].[IsCompleted] AS [IsCompleted], [Project6].[PartialTag] AS [PartialTag], [Project6].[ID] AS [ID], [Project6].[Name] AS [Name], [Project6].[timestamp2] AS [timestamp2], [Project6].[ZoneID1] AS [ZoneID1], [Project6].[Name1] AS [Name1], [Project6].[DataCenterID1] AS [DataCenterID1], [Project6].[AssetTypeID] AS [AssetTypeID], [Project6].[Name2] AS [Name2], [Project6].[IncludedInSearch] AS [IncludedInSearch]
FROM ( SELECT [Project6].[ITRackID] AS [ITRackID], [Project6].[DataCenterID] AS [DataCenterID], [Project6].[ZoneID] AS [ZoneID], [Project6].[timestamp] AS [timestamp], [Project6].[IT360SiteID] AS [IT360SiteID], [Project6].[TechnologyID] AS [TechnologyID], [Project6].[Tag] AS [Tag], [Project6].[IsDeleted] AS [IsDeleted], [Project6].[timestamp1] AS [timestamp1], [Project6].[TypeID] AS [TypeID], [Project6].[StartDate] AS [StartDate], [Project6].[IT360ID] AS [IT360ID], [Project6].[IsCompleted] AS [IsCompleted], [Project6].[PartialTag] AS [PartialTag], [Project6].[ID] AS [ID], [Project6].[Name] AS [Name], [Project6].[timestamp2] AS [timestamp2], [Project6].[ZoneID1] AS [ZoneID1], [Project6].[Name1] AS [Name1], [Project6].[DataCenterID1] AS [DataCenterID1], [Project6].[AssetTypeID] AS [AssetTypeID], [Project6].[Name2] AS [Name2], [Project6].[IncludedInSearch] AS [IncludedInSearch], row_number() OVER (ORDER BY [Project6].[Name] ASC) AS [row_number]
FROM ( SELECT
[Extent13].[ITRackID] AS [ITRackID],
[Extent13].[DataCenterID] AS [DataCenterID],
[Extent13].[ZoneID] AS [ZoneID],
[Extent13].[timestamp] AS [timestamp],
[Extent13].[IT360SiteID] AS [IT360SiteID],
[Extent14].[TechnologyID] AS [TechnologyID],
[Extent14].[Tag] AS [Tag],
[Extent14].[IsDeleted] AS [IsDeleted],
[Extent14].[timestamp] AS [timestamp1],
[Extent14].[TypeID] AS [TypeID],
[Extent14].[StartDate] AS [StartDate],
[Extent14].[IT360ID] AS [IT360ID],
[Extent14].[IsCompleted] AS [IsCompleted],
[Extent14].[PartialTag] AS [PartialTag],
[Extent15].[ID] AS [ID],
[Extent15].[Name] AS [Name],
[Extent15].[timestamp] AS [timestamp2],
[Extent16].[ZoneID] AS [ZoneID1],
[Extent16].[Name] AS [Name1],
[Extent16].[DataCenterID] AS [DataCenterID1],
[Extent17].[AssetTypeID] AS [AssetTypeID],
[Extent17].[Name] AS [Name2],
[Extent17].[IncludedInSearch] AS [IncludedInSearch]
FROM [dbo].[ITRacks] AS [Extent13]
INNER JOIN [dbo].[Technology] AS [Extent14] ON [Extent13].[ITRackID] = [Extent14].[TechnologyID]
INNER JOIN [dbo].[DataCenter] AS [Extent15] ON [Extent13].[DataCenterID] = [Extent15].[ID]
INNER JOIN [dbo].[Zones] AS [Extent16] ON [Extent13].[ZoneID] = [Extent16].[ZoneID]
LEFT OUTER JOIN [dbo].[TechnologyTypes] AS [Extent17] ON [Extent14].[TypeID] = [Extent17].[AssetTypeID]
WHERE (@p__linq__0 IS NULL) OR (( CAST(LEN(@p__linq__0) AS int)) = 0) OR (( CAST(CHARINDEX(UPPER(@p__linq__1), UPPER([Extent14].[Tag])) AS int)) = 1)
) AS [Project6]
) AS [Project6]
WHERE [Project6].[row_number] > 0
ORDER BY [Project6].[Name] ASC ) AS [Limit3]
INNER JOIN [dbo].[ITServers] AS [Extent18] ON [Limit3].[ITRackID] = [Extent18].[RackID]) AS [UnionAll2]
UNION ALL
SELECT
4 AS [C1],
//code goes here
[Limit4].[Tag] AS [Tag],
[Limit4].[IsDeleted] AS [IsDeleted],
[Limit4].[timestamp1] AS [timestamp2],
[Limit4].[TypeID] AS [TypeID],
[Limit4].[StartDate] AS [StartDate],
[Limit4].[IT360ID] AS [IT360ID],
[Limit4].[IsCompleted] AS [IsCompleted],
[Limit4].[PartialTag] AS [PartialTag],
[Limit4].[AssetTypeID] AS [AssetTypeID],
[Limit4].[Name2] AS [Name3],
[Limit4].[IncludedInSearch] AS [IncludedInSearch],
CAST(NULL AS int) AS [C2],
//code goes here
[Extent24].[IT360SiteID] AS [IT360SiteID1],
CAST(NULL AS int) AS [C32],
CAST(NULL AS int) AS [C33],
CAST(NULL AS varchar(1)) AS [C34],
CAST(NULL AS int) AS [C35],
CAST(NULL AS int) AS [C36],
CAST(NULL AS varchar(1)) AS [C37],
CAST(NULL AS varchar(1)) AS [C38],
CAST(NULL AS varchar(1)) AS [C39],
CAST(NULL AS bigint) AS [C40],
CAST(NULL AS varbinary(1)) AS [C41]
FROM (SELECT TOP (15) [Project9].[ITRackID] AS [ITRackID], [Project9].[DataCenterID] AS [DataCenterID], [Project9].[ZoneID] AS [ZoneID], [Project9].[timestamp] AS [timestamp], [Project9].[IT360SiteID] AS [IT360SiteID], [Project9].[TechnologyID] AS [TechnologyID], [Project9].[Tag] AS [Tag], [Project9].[IsDeleted] AS [IsDeleted], [Project9].[timestamp1] AS [timestamp1], [Project9].[TypeID] AS [TypeID], [Project9].[StartDate] AS [StartDate], [Project9].[IT360ID] AS [IT360ID], [Project9].[IsCompleted] AS [IsCompleted], [Project9].[PartialTag] AS [PartialTag], [Project9].[ID] AS [ID], [Project9].[Name] AS [Name], [Project9].[timestamp2] AS [timestamp2], [Project9].[ZoneID1] AS [ZoneID1], [Project9].[Name1] AS [Name1], [Project9].[DataCenterID1] AS [DataCenterID1], [Project9].[AssetTypeID] AS [AssetTypeID], [Project9].[Name2] AS [Name2], [Project9].[IncludedInSearch] AS [IncludedInSearch]
FROM ( SELECT [Project9].[ITRackID] AS [ITRackID], [Project9].[DataCenterID] AS [DataCenterID], [Project9].[ZoneID] AS [ZoneID], [Project9].[timestamp] AS [timestamp], [Project9].[IT360SiteID] AS [IT360SiteID], [Project9].[TechnologyID] AS [TechnologyID], [Project9].[Tag] AS [Tag], [Project9].[IsDeleted] AS [IsDeleted], [Project9].[timestamp1] AS [timestamp1], [Project9].[TypeID] AS [TypeID], [Project9].[StartDate] AS [StartDate], [Project9].[IT360ID] AS [IT360ID], [Project9].[IsCompleted] AS [IsCompleted], [Project9].[PartialTag] AS [PartialTag], [Project9].[ID] AS [ID], [Project9].[Name] AS [Name], [Project9].[timestamp2] AS [timestamp2], [Project9].[ZoneID1] AS [ZoneID1], [Project9].[Name1] AS [Name1], [Project9].[DataCenterID1] AS [DataCenterID1], [Project9].[AssetTypeID] AS [AssetTypeID], [Project9].[Name2] AS [Name2], [Project9].[IncludedInSearch] AS [IncludedInSearch], row_number() OVER (ORDER BY [Project9].[Name] ASC) AS [row_number]
FROM ( SELECT
[Extent19].[ITRackID] AS [ITRackID],
[Extent19].[DataCenterID] AS [DataCenterID],
[Extent19].[ZoneID] AS [ZoneID],
[Extent19].[timestamp] AS [timestamp],
[Extent19].[IT360SiteID] AS [IT360SiteID],
//code goes here
[Extent23].[IncludedInSearch] AS [IncludedInSearch]
FROM [dbo].[ITRacks] AS [Extent19]
INNER JOIN [dbo].[Technology] AS [Extent20] ON [Extent19].[ITRackID] = [Extent20].[TechnologyID]
INNER JOIN [dbo].[DataCenter] AS [Extent21] ON [Extent19].[DataCenterID] = [Extent21].[ID]
INNER JOIN [dbo].[Zones] AS [Extent22] ON [Extent19].[ZoneID] = [Extent22].[ZoneID]
LEFT OUTER JOIN [dbo].[TechnologyTypes] AS [Extent23] ON [Extent20].[TypeID] = [Extent23].[AssetTypeID]
WHERE (@p__linq__0 IS NULL) OR (( CAST(LEN(@p__linq__0) AS int)) = 0) OR (( CAST(CHARINDEX(UPPER(@p__linq__1), UPPER([Extent20].[Tag])) AS int)) = 1)
) AS [Project9]
) AS [Project9]
WHERE [Project9].[row_number] > 0
ORDER BY [Project9].[Name] ASC ) AS [Limit4]
INNER JOIN [dbo].[ITStorageDevices] AS [Extent24] ON [Limit4].[ITRackID] = [Extent24].[RackID]) AS [UnionAll3]
UNION ALL
SELECT
5 AS [C1],
//code goes here
CAST(NULL AS int) AS [C26],
CAST(NULL AS int) AS [C27],
CAST(NULL AS int) AS [C28],
CAST(NULL AS varbinary(1)) AS [C30],
CAST(NULL AS bigint) AS [C31],
CAST(NULL AS int) AS [C32],
CAST(NULL AS decimal(8,2)) AS [C33],
CAST(NULL AS int) AS [C34],
CAST(NULL AS varchar(1)) AS [C35],
CAST(NULL AS varbinary(1)) AS [C36],
CAST(NULL AS bigint) AS [C37],
[Extent30].[SwitchID] AS [SwitchID],
[Extent30].[ModelID] AS [ModelID],
[Extent30].[Spec] AS [Spec],
[Extent30].[RackID] AS [RackID],
[Extent30].[ConsoleServerID] AS [ConsoleServerID],
[Extent30].[ConsoleServerIpIn] AS [ConsoleServerIpIn],
[Extent30].[ConsoleServerIpOut] AS [ConsoleServerIpOut],
[Extent30].[Description] AS [Description],
[Extent30].[IT360SiteID] AS [IT360SiteID1],
[Extent30].[timestamp] AS [timestamp3]
FROM (SELECT TOP (15) [Project12].[ITRackID] AS [ITRackID], [Project12].[DataCenterID] AS [DataCenterID], [Project12].[ZoneID] AS [ZoneID], [Project12].[timestamp] AS [timestamp], [Project12].[IT360SiteID] AS [IT360SiteID], [Project12].[TechnologyID] AS [TechnologyID], [Project12].[Tag] AS [Tag], [Project12].[IsDeleted] AS [IsDeleted], [Project12].[timestamp1] AS [timestamp1], [Project12].[TypeID] AS [TypeID], [Project12].[StartDate] AS [StartDate], [Project12].[IT360ID] AS [IT360ID], [Project12].[IsCompleted] AS [IsCompleted], [Project12].[PartialTag] AS [PartialTag], [Project12].[ID] AS [ID], [Project12].[Name] AS [Name], [Project12].[timestamp2] AS [timestamp2], [Project12].[ZoneID1] AS [ZoneID1], [Project12].[Name1] AS [Name1], [Project12].[DataCenterID1] AS [DataCenterID1], [Project12].[AssetTypeID] AS [AssetTypeID], [Project12].[Name2] AS [Name2], [Project12].[IncludedInSearch] AS [IncludedInSearch]
FROM ( SELECT [Project12].[ITRackID] AS [ITRackID], [Project12].[DataCenterID] AS [DataCenterID], [Project12].[ZoneID] AS [ZoneID], [Project12].[timestamp] AS [timestamp], [Project12].[IT360SiteID] AS [IT360SiteID], [Project12].[TechnologyID] AS [TechnologyID], [Project12].[Tag] AS [Tag], [Project12].[IsDeleted] AS [IsDeleted], [Project12].[timestamp1] AS [timestamp1], [Project12].[TypeID] AS [TypeID], [Project12].[StartDate] AS [StartDate], [Project12].[IT360ID] AS [IT360ID], [Project12].[IsCompleted] AS [IsCompleted], [Project12].[PartialTag] AS [PartialTag], [Project12].[ID] AS [ID], [Project12].[Name] AS [Name], [Project12].[timestamp2] AS [timestamp2], [Project12].[ZoneID1] AS [ZoneID1], [Project12].[Name1] AS [Name1], [Project12].[DataCenterID1] AS [DataCenterID1], [Project12].[AssetTypeID] AS [AssetTypeID], [Project12].[Name2] AS [Name2], [Project12].[IncludedInSearch] AS [IncludedInSearch], row_number() OVER (ORDER BY [Project12].[Name] ASC) AS [row_number]
FROM ( SELECT
//code goes here
[Extent29].[IncludedInSearch] AS [IncludedInSearch]
FROM [dbo].[ITRacks] AS [Extent25]
INNER JOIN [dbo].[Technology] AS [Extent26] ON [Extent25].[ITRackID] = [Extent26].[TechnologyID]
INNER JOIN [dbo].[DataCenter] AS [Extent27] ON [Extent25].[DataCenterID] = [Extent27].[ID]
INNER JOIN [dbo].[Zones] AS [Extent28] ON [Extent25].[ZoneID] = [Extent28].[ZoneID]
LEFT OUTER JOIN [dbo].[TechnologyTypes] AS [Extent29] ON [Extent26].[TypeID] = [Extent29].[AssetTypeID]
WHERE (@p__linq__0 IS NULL) OR (( CAST(LEN(@p__linq__0) AS int)) = 0) OR (( CAST(CHARINDEX(UPPER(@p__linq__1), UPPER([Extent26].[Tag])) AS int)) = 1)
) AS [Project12]
) AS [Project12]
WHERE [Project12].[row_number] > 0
ORDER BY [Project12].[Name] ASC ) AS [Limit5]
INNER JOIN [dbo].[ITSwitches] AS [Extent30] ON [Limit5].[ITRackID] = [Extent30].[RackID]) AS [UnionAll4]
ORDER BY [UnionAll4].[C2] ASC, [UnionAll4].[C3] ASC, [UnionAll4].[C4] ASC, [UnionAll4].[C5] ASC, [UnionAll4].[C6] ASC, [UnionAll4].[C7] ASC, [UnionAll4].[C8] ASC, [UnionAll4].[C10] ASC, [UnionAll4].[C15] ASC, [UnionAll4].[C18] ASC, [UnionAll4].[C22] ASC, [UnionAll4].[C31] ASC, [UnionAll4].[C1] ASC',N'@p__linq__0 nvarchar(4000),@p__linq__1 nvarchar(4000)',@p__linq__0=N'',@p__linq__1=N''