google-code-export / dataobjectsdotnet

Automatically exported from code.google.com/p/dataobjectsdotnet
0 stars 0 forks source link

Column naming error #806

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
var query =
        from kalinaGasObject in Query.All<Data.Kalina.PipeAbonent>()
        let matchGuess = Query.All<Kalina2RngGasObjectMatchGuess>().Where(
          g => g.KalinaPipeAbonentID==kalinaGasObject.Id).FirstOrDefault()
        let matchGuessObject = Query.All<Rng.GasObject>().Where(go => go.Id==matchGuess.RngGasObjectID).FirstOrDefault()
        let owner = Query.All<Data.Kalina.PipeAbonentOwnershipInfo>().Where(
          ao =>
            ao.Abonent==kalinaGasObject &&
              (ao.BeginDate==null || ao.BeginDate <= today) &&
                (ao.EndDate==null || ao.EndDate >= today)).FirstOrDefault()
        let unifiedGasObject = Query.All<Data.Unit.UnifiedGasObject>().Where(
          ua => ua.KalinaGasObject==kalinaGasObject && ua.RngGasObject!=null).FirstOrDefault()
        orderby matchGuess.Rank ?? 0 descending
        select new Kalina2RngGasObjectMatchListItem {
          LeftID = kalinaGasObject.Id,
          LeftName = owner.Name ?? kalinaGasObject.Name,
          LeftPatronymic = owner.Patronymic,
          LeftSurname = owner.Surname,
          Status = unifiedGasObject==null ? MatchStatus.NotConfirmed : MatchStatus.Confirmed,
          Right = unifiedGasObject==null
            ? GetMatch(matchGuessObject)
            : GetMatch(unifiedGasObject.RngGasObject)
        };

попытка взвать query.Count() приводит к 

Error 'Unknown' while executing query 'SELECT COUNT_BIG(*) AS [column1] FROM 
(SELECT [a].[Id], [a].[TypeId], [a].[RegistrationDate], [a].[StartDate], 
[a].[Number], [a].[Street.Id], [a].[House], [a].[Building], [a].[Room], 
[a].[Name], [a].[InstructionDate], [a].[ConnectionPoint.Id], [a].[State], 
[a].[SwitchDate], [a].[StateCause], [a].[TenantCount], [a].[HouseType.Id], 
[a].[StartWorker.Id], [a].[StartNote], [a].[EquipmentNote], 
[a].[SchemaFileName], [a].[ArchiveDate], [a].[ArchiveCause.Id], 
[a].[Privilege.Id], [a].[PrivilegeDate], [a].[IsArchived], 
[a].[IsRepresentedInMapInfo], [a].[IsMarkedAsRemoved], [a].[Facility.Id], 
[a].[ExternalId], [a].[ImportedEntityInfo.ImportDate], 
[a].[ImportedEntityInfo.ImportSource], [b].[#a.RngGasObjectID], [b].[#a.Rank], 
[c].[NULL], [d].[NULL], [e].[#d.RngGasObject.Id], COALESCE([b].[#a.Rank], 
cast(0.0e0 as float)) AS [column] FROM (SELECT [f].[Id], 180 AS [TypeId], 
[f].[RegistrationDate], [f].[StartDate], [f].[Number], [f].[Street.Id], 
[f].[House], [f].[Building], [f].[Room], [f].[Name], [f].[InstructionDate], 
[f].[ConnectionPoint.Id], [f].[State], [f].[SwitchDate], [f].[StateCause], 
[f].[TenantCount], [f].[HouseType.Id], [f].[StartWorker.Id], [f].[StartNote], 
[f].[EquipmentNote], [f].[SchemaFileName], [f].[ArchiveDate], 
[f].[ArchiveCause.Id], [f].[Privilege.Id], [f].[PrivilegeDate], 
[f].[IsArchived], [f].[IsRepresentedInMapInfo], [f].[IsMarkedAsRemoved], 
[f].[Facility.Id], [f].[ExternalId], [f].[ImportedEntityInfo.ImportDate], 
[f].[ImportedEntityInfo.ImportSource] FROM [dbo].[Egs.Data.Kalina.PipeAbonent] 
[f]) [a] OUTER APPLY (SELECT TOP 1 [g].[RngGasObjectID] AS [#a.RngGasObjectID], 
[g].[Rank] AS [#a.Rank] FROM 
[dbo].[Egs.Data.Unit.Kalina2RngGasObjectMatchGuess] [g] WHERE 
([g].[KalinaPipeAbonentID] = [a].[Id]) ORDER BY [g].[ID] ASC) [b] OUTER APPLY 
(SELECT TOP 1 NULL AS [NULL] FROM [dbo].[Egs.Data.Rng.GasObject] [h] WHERE 
([h].[Id] = [b].[#a.RngGasObjectID]) ORDER BY [h].[Id] ASC) [c] OUTER APPLY 
(SELECT TOP 1 NULL AS [NULL] FROM 
[dbo].[Egs.Data.Kalina.PipeAbonentOwnershipInfo] [i] WHERE ((([i].[Abonent.Id] 
= [a].[Id]) AND (([i].[BeginDate] IS NULL) OR ([i].[BeginDate] <= @p0_0))) AND 
(([i].[EndDate] IS NULL) OR ([i].[EndDate] >= @p0_1))) ORDER BY [i].[Id] ASC) 
[d] OUTER APPLY (SELECT TOP 1 [j].[RngGasObject.Id] AS [#d.RngGasObject.Id] 
FROM [dbo].[Egs.Data.Unit.UnifiedGasObject] [j] WHERE 
(([j].[KalinaGasObject.Id] = [a].[Id]) AND ([j].[RngGasObject.Id] IS NOT NULL)) 
ORDER BY [j].[ID] ASC) [e]) [k] LEFT OUTER JOIN (SELECT [l].[Id] AS [#e.Id], 
228 AS [#e.TypeId], [l].[GasSite] AS [#e.GasSite], [l].[AccountNumber] AS 
[#e.AccountNumber], [l].[GasObjectType] AS [#e.GasObjectType], [l].[Customer] 
AS [#e.Customer], [l].[NotActual] AS [#e.NotActual], [l].[Area] AS [#e.Area], 
[l].[Town] AS [#e.Town], [l].[Street] AS [#e.Street], [l].[Building] AS 
[#e.Building], [l].[Case] AS [#e.Case], [l].[Apartment] AS [#e.Apartment], 
[l].[Zip] AS [#e.Zip], [l].[AgreementDate] AS [#e.AgreementDate], 
[l].[AgreementNumber] AS [#e.AgreementNumber], [l].[TenantCount] AS 
[#e.TenantCount], [l].[Phones] AS [#e.Phones], [l].[CentralHeating] AS 
[#e.CentralHeating], [l].[MeterCount] AS [#e.MeterCount], [l].[SquareCount] AS 
[#e.SquareCount], [l].[EquipmentCount] AS [#e.EquipmentCount], [l].[Comment] AS 
[#e.Comment], [l].[Needy] AS [#e.Needy], [l].[GasDistributionCompany] AS 
[#e.GasDistributionCompany], [l].[GasDistributionStation] AS 
[#e.GasDistributionStation], [l].[OblGasCode] AS [#e.OblGasCode], 
[l].[ImportedEntityInfo.ImportDate] AS [#e.ImportedEntityInfo.ImportDate], 
[l].[ImportedEntityInfo.ImportSource] AS [#e.ImportedEntityInfo.ImportSource], 
[l].[ExternalId] AS [#e.ExternalId] FROM [dbo].[Egs.Data.Rng.GasObject] [l]) 
[m] ON ([k].[NULL] = [m].[#e.Id]); [p0_0='13.09.2010 0:00:00';p0_1='13.09.2010 
0:00:00']'. Original message: The column 'NULL' was specified multiple times 
for 'k'.
[12:14:54] Alex Ilyin: query.Take(100).ToList() возвращает всё 
как надо

Original issue reported on code.google.com by alexey.g...@gtempaccount.com on 13 Sep 2010 at 7:50

GoogleCodeExporter commented 9 years ago

Original comment by alexey.g...@gtempaccount.com on 13 Sep 2010 at 3:44

GoogleCodeExporter commented 9 years ago

Original comment by alexey.g...@gtempaccount.com on 15 Sep 2010 at 3:13