Full Text Search not working please help me.
A Database Error Occurred
Error Number: 42000
[Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Full-Text Search
is not installed, or a full-text component cannot be loaded.
SELECT judg.id
,judg.jud_no
,judg.jud_year
,judg.book_reference
,judg.jurisdiction
,judg.case_no
,judg.case_source
,judg.parties
,judg.lawyer
,judg.judgment_date
,judg.j_date
,judg.judgment_date_type
,judg.short_description
,judg.section
,judg.act
,judg.article
,judg.order_rule
,judg.full_judgment
,judg.judgment_type
,judg.court_division_id
,judg.file_name
,judg.file_rename
,judg.judgment_entry_date
,judg.STATUS
,judg.user_id
,judg.is_pdf
,judg.is_table
,judg.is_correction
,ct.name AS ct_name
,cd.name AS cd_name
FROM tbl_jud_judgment judg
LEFT JOIN tbl_jud_case_type_no_year ctny ON ctny.judgment_id = judg.id
LEFT JOIN tbl_jud_case_type ct ON ct.id = ctny.case_type_id
LEFT JOIN tbl_jud_court_division cd ON cd.id = judg.court_division_id
LEFT JOIN tbl_jud_justice_judgment cjud ON cjud.judgment_id = judg.id
LEFT JOIN tbl_jud_justice cjus ON cjus.id = cjud.justice_id
WHERE 1 = 1
AND (
judg.case_no LIKE '%dhaka%'
OR judg.parties LIKE N'%dhaka%'
OR (
CONTAINS (
judg.full_judgment
,'"*dhaka*"'
)
AND judg.full_judgment LIKE N'%dhaka%'
)
OR cd.name LIKE '%dhaka%'
OR ct.name LIKE '%dhaka%'
OR cjus.name LIKE '%dhaka%'
OR judg.short_description LIKE N'%dhaka%'
)
AND judg.STATUS = 1
GROUP BY judg.id
,judg.jud_no
,judg.jud_year
,judg.book_reference
,judg.jurisdiction
,judg.case_no
,judg.case_source
,judg.parties
,judg.lawyer
,judg.judgment_date
,judg.j_date
,judg.judgment_date_type
,judg.short_description
,judg.section
,judg.act
,judg.article
,judg.order_rule
,judg.full_judgment
,judg.judgment_type
,judg.court_division_id
,judg.file_name
,judg.file_rename
,judg.judgment_entry_date
,judg.STATUS
,judg.user_id
,judg.is_pdf
,judg.is_table
,judg.is_correction
,ct.name
,cd.name
ORDER BY judg.jud_year DESC
,judg.jud_no DESC
,judg.judgment_date DESC OFFSET 0 ROWS
FETCH NEXT 50 ROWS ONLY
Filename:
C:\inetpub\vhosts\janatajobs.com\httpdocs\lcms_sys\database\DB_driver.php
Line Number: 331
Verify following:
SQL Full-text filter Daemon Launcher service running along with SQL Service, if not available, you may want install it
Once Full-text service started, verify Full Text Catalogs been configured in particular database (via SSMS - Database - Storage - Full Text Catalogs). for detailed steps
Related
I am using EF Core for my .NET Core 2.1 project to interact with Azure SQL Server.
I have query which fetches around 1.5L rows by joining multiple tables. It's taking a long time to return the result and it is getting timed out (more than 30 seconds). So I am going with pagination using skip and take.
So my final call looks like
query.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList();
This call works absolutely fine and give the expected results.
But when I add order by clause to this query:
query.OrderBy(sortField)
.Skip((pageNumber - 1) * pageSize).Take(pageSize).ToList()
Below is the generated SQL
SELECT [p].[Id], [p].[CreatedById], [p].[CreatedOn], [p].[CurrencyId], [p].[CustomerId], [p].[DataMigrationLogId], [p].[FollowUp], [p].[IsActive], [p].[ProjectName], [p].[PlantCode], [p].[ShipToDistanceFromPlant], [p].[StatusId],
[p].[UpdatedById], [p].[UpdatedOn], [p.DataMigrationLog].[Id], [p.DataMigrationLog].[CreatedOn], [p.DataMigrationLog].[GeneratedOn], [p.DataMigrationLog].[HasEdsBid], [p.DataMigrationLog].[HasMbiBid], [p.DataMigrationLog].[Log],
[p.DataMigrationLog].[RequestXml], [p.DataMigrationLog].[Status], [p.DataMigrationLog].[Xq1ProjectId], [p.UpdatedBy].[Id], [p.UpdatedBy].[CellPhone], [p.UpdatedBy].[CreatedOn], [p.UpdatedBy].[Discriminator], [p.UpdatedBy].[Email],
[p.UpdatedBy].[FirstName], [p.UpdatedBy].[HasAccessToDoors], [p.UpdatedBy].[HasAccessToWindows], [p.UpdatedBy].[IsActive], [p.UpdatedBy].[LastName], [p.UpdatedBy].[Prefix], [p.UpdatedBy].[RecentProjectId], [p.UpdatedBy].[UpdatedOn],
[p.UpdatedBy].[WorkPhone], [p.UpdatedBy].[XQ1LoginName], [p.UpdatedBy].[IsSuperAdmin], [p.UpdatedBy].[HasAccessToRestrictedReports], [p.UpdatedBy].[HasEdsProgramAndDealerPriceAccess], [p.UpdatedBy].[IsIss],
[p.UpdatedBy].[ProjectVisibilityId], [p.UpdatedBy].[CustomerId], [p.UpdatedBy].[IsApiUser], [p.CreatedBy].[Id], [p.CreatedBy].[CellPhone], [p.CreatedBy].[CreatedOn], [p.CreatedBy].[Discriminator], [p.CreatedBy].[Email],
[p.CreatedBy].[FirstName], [p.CreatedBy].[HasAccessToDoors], [p.CreatedBy].[HasAccessToWindows], [p.CreatedBy].[IsActive], [p.CreatedBy].[LastName], [p.CreatedBy].[Prefix], [p.CreatedBy].[RecentProjectId], [p.CreatedBy].[UpdatedOn],
[p.CreatedBy].[WorkPhone], [p.CreatedBy].[XQ1LoginName], [p.CreatedBy].[IsSuperAdmin], [p.CreatedBy].[HasAccessToRestrictedReports], [p.CreatedBy].[HasEdsProgramAndDealerPriceAccess], [p.CreatedBy].[IsIss],
[p.CreatedBy].[ProjectVisibilityId], [p.CreatedBy].[CustomerId], [p.CreatedBy].[IsApiUser], [p.Status].[Id], [p.Status].[Code], [p.Status].[Name], [p.Customer].[Id], [p.Customer].[AxCustomerNumber], [p.Customer].[CreatedById],
[p.Customer].[CreatedOn], [p.Customer].[CreditTermId], [p.Customer].[CurrencyId], [p.Customer].[CustomerTypeId], [p.Customer].[DefaultPricing], [p.Customer].[FabricSystemFreight], [p.Customer].[IsActive], [p.Customer].[IsSpecialFreight],
[p.Customer].[LocalityRepId], [p.Customer].[MinFreightCharge], [p.Customer].[CompanyName], [p.Customer].[Notes], [p.Customer].[PrimaryBusinessId], [p.Customer].[ProgramAccountId], [p.Customer].[Prospect],
[p.Customer].[ShippingDollarsThreshold], [p.Customer].[ShippingMilesThreshold], [p.Customer].[SpecialNote], [p.Customer].[SpecialPlantInstruction], [p.Customer].[UpdatedById], [p.Customer].[UpdatedOn],
[p.Customer].[Xq1ProgGroupName], [p.Customer].[Xq1SrNo], [p.Customer].[XqCustomerNumber], [p.Customer.ProgramAccount].[Id], [p.Customer.ProgramAccount].[AxCustomerNumber], [p.Customer.ProgramAccount].[CreatedById],
[p.Customer.ProgramAccount].[CreatedOn], [p.Customer.ProgramAccount].[CreditTermId], [p.Customer.ProgramAccount].[CurrencyId], [p.Customer.ProgramAccount].[CustomerTypeId], [p.Customer.ProgramAccount].[DefaultPricing],
[p.Customer.ProgramAccount].[FabricSystemFreight], [p.Customer.ProgramAccount].[IsActive], [p.Customer.ProgramAccount].[IsSpecialFreight], [p.Customer.ProgramAccount].[LocalityRepId], [p.Customer.ProgramAccount].[MinFreightCharge],
[p.Customer.ProgramAccount].[CompanyName], [p.Customer.ProgramAccount].[Notes], [p.Customer.ProgramAccount].[PrimaryBusinessId], [p.Customer.ProgramAccount].[ProgramAccountId], [p.Customer.ProgramAccount].[Prospect],
[p.Customer.ProgramAccount].[ShippingDollarsThreshold], [p.Customer.ProgramAccount].[ShippingMilesThreshold], [p.Customer.ProgramAccount].[SpecialNote], [p.Customer.ProgramAccount].[SpecialPlantInstruction],
[p.Customer.ProgramAccount].[UpdatedById], [p.Customer.ProgramAccount].[UpdatedOn], [p.Customer.ProgramAccount].[Xq1ProgGroupName], [p.Customer.ProgramAccount].[Xq1SrNo], [p.Customer.ProgramAccount].[XqCustomerNumber],
[p.Customer.CustomerType].[Id], [p.Customer.CustomerType].[Code], [p.Customer.CustomerType].[Name]
FROM [Projects] AS [p]
LEFT JOIN [DataMigrationLogs] AS [p.DataMigrationLog] ON [p].[DataMigrationLogId] = [p.DataMigrationLog].[Id]
INNER JOIN [Security].[XQUsers] AS [p.UpdatedBy] ON [p].[UpdatedById] = [p.UpdatedBy].[Id]
INNER JOIN [Security].[XQUsers] AS [p.CreatedBy] ON [p].[CreatedById] = [p.CreatedBy].[Id]
INNER JOIN [ProjectStatuses] AS [p.Status] ON [p].[StatusId] = [p.Status].[Id]
LEFT JOIN [Customers] AS [p.Customer] ON [p].[CustomerId] = [p.Customer].[Id]
LEFT JOIN (
SELECT [p.Customer.LocalityRep].*
FROM [Security].[XQUsers] AS [p.Customer.LocalityRep]
WHERE [p.Customer.LocalityRep].[Discriminator] = N'SALES_SP'
) AS [t] ON [p.Customer].[LocalityRepId] = [t].[Id]
LEFT JOIN [Customers] AS [p.Customer.ProgramAccount] ON [p.Customer].[ProgramAccountId] = [p.Customer.ProgramAccount].[Id]
LEFT JOIN (
SELECT [p.Customer.ProgramAccount.LocalityRep].*
FROM [Security].[XQUsers] AS [p.Customer.ProgramAccount.LocalityRep]
WHERE [p.Customer.ProgramAccount.LocalityRep].[Discriminator] = N'SALES_SP'
) AS [t0] ON [p.Customer.ProgramAccount].[LocalityRepId] = [t0].[Id]
LEFT JOIN [CustomerTypes] AS [p.Customer.CustomerType] ON [p.Customer].[CustomerTypeId] = [p.Customer.CustomerType].[Id]
WHERE ([p.UpdatedBy].[Discriminator] IN (N'INT_SYSADMMIN', N'XqInternalUser', N'EXT', N'SALES_SP', N'XqUser') AND [p.CreatedBy].[Discriminator] IN (N'INT_SYSADMMIN', N'XqInternalUser', N'EXT', N'SALES_SP', N'XqUser')) AND (EXISTS (
SELECT 1
FROM [Security].[BusinessUserRegions] AS [r]
WHERE [r].[RegionId] IN (CAST(6 AS bigint), CAST(8 AS bigint), CAST(9 AS bigint)) AND ([t].[Id] = [r].[BusinessUserId])) OR ([p.Customer].[ProgramAccountId] IS NOT NULL AND EXISTS (
SELECT 1
FROM [Security].[BusinessUserRegions] AS [r0]
WHERE [r0].[RegionId] IN (CAST(6 AS bigint), CAST(8 AS bigint), CAST(9 AS bigint)) AND ([t0].[Id] = [r0].[BusinessUserId]))))
ORDER BY [p].[CreatedOn]
It takes more than 30 seconds to execute and Azure SQL Server has query timeout of maximum 30 second, so it results in exception
System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
From my layman's understanding about SQL I think SQL us fetching the entire dataset for sorting and then trying to do pagination and hence it's taking more than 30 seconds. Please correct me if I am wrong.
I need to sort the result in query in self otherwise it will not provide the desired result set.
Is their any way to deal with this situation.
Any help is highly appreciated.
My SQL Server query below fails on:
sys_connect_by_path(folder_names.name, '//') "PATH"
I believe it was created in Oracle. Can someone help replace that bit of code with the 2016 SQL Server equivalent ?
select -- report, package,
path
from (
select report_names.name "REPORT"
, sys_connect_by_path(folder_names.name, '//') "PATH"
, package_names.name "PACKAGE"
from cognos_cs.cmobjects folders
join cognos_cs.cmobjnames folder_names on folders.cmid = folder_names.cmid and folder_names.isdefault = 1
left join cognos_cs.cmobjects reports on folders.cmid = reports.pcmid and reports.classid = 10
left join cognos_cs.cmobjnames report_names on reports.cmid = report_names.cmid and report_names.isdefault = 1
left join cognos_cs.cmrefnoord1 packages on reports.cmid = packages.cmid and packages.propid = 31
left join cognos_cs.cmobjnames package_names on packages.refcmid = package_names.cmid and package_names.isdefault = 1
where folders.classid = 1
start with folders.cmid = 2
connect by prior folders.cmid = folders.pcmid
) group by -- report, package,
path
order by path
;
Getting Error in MS ACCESS 2007,
Error: Error at Command Line:15 Column:11 Error report: SQL Error: ORA-00936: missing expression 00936. 00000 - "missing expression"
Under SQL Pass Through Query i was trying to run below query:
tbl_Loss_Curr_Day - SQL Linked table
tbl_Loss_Prior_Day - SQL Linked table
PCOMMON - Oracle linked table
PROGRAM_CODE - Oracle linked table
BUSINESS_UNIT- - Oracle linked table
SELECT LC.num_policy_x,
LC.num_edition,
LC.cde_company,
LC.num_claim,
LC.cde_accident_state_abbr,
LC.nme_insured,
LC.dte_loss,
LC.nme_adjuster,
LC.cde_bus_unit,
LC.dte_reported,
PC.AC_FLAG,
PC.G78_PROGRAM_CODE,
LPC.G78_DESCRIPTION,
BU.R21_DESCRIPTION,
Sum([LC].[amt_dir_resv]-(IsNull([LP].[amt_dir_resv],0))) AS Loss_Resv,
Sum([LC].[amt_exp_resv]-(IsNull([LP].[amt_exp_resv],0))) AS Exp_Resv,
Sum(([LC].[amt_dir_paid]-(IsNull([LP].[amt_dir_paid],0)))-([LC].[amt_dir_rcvrd]-(IsNull([LP].[amt_dir_rcvrd],0)))) AS Loss_Paid,
Sum(([LC].[amt_exp_paid]-(IsNull([LP].[amt_exp_paid],0)))-([LC].[amt_exp_rcvrd]-(IsNull([LP].[amt_exp_rcvrd],0)))) AS Exp_Paid,
Sum(IsNull([LP].[amt_dir_incurred],0)) AS Loss_BegIncurred, Sum(IsNull([LC].[amt_dir_incurred],0)) AS Loss_EndIncurred,
Sum(IsNull([LP].[amt_exp_incurred],0)) AS Exp_BegIncurred, Sum(IsNull([LC].[amt_exp_incurred],0)) AS Exp_EndIncurred,
Sum([LC].[amt_dir_incurred]-(IsNull([LP].[amt_dir_incurred],0))) AS Loss_ChgIncurred,
Sum([LC].[amt_exp_incurred]-(IsNull([LP].[amt_exp_incurred],0))) AS Exp_ChgIncurred FROM ((((tbl_Loss_Curr_Day AS LC
LEFT JOIN tbl_Loss_Prior_Day AS LP ON LC.cde_coverage = LP.cde_coverage
AND LC.num_unit = LP.num_unit
AND LC.num_claim = LP.num_claim
AND LC.num_claim_sfx = LP.num_claim_sfx)
LEFT JOIN PCOMMON AS PC ON LC.cde_bus_unit=PC.R21_BUSINESS_UNIT
AND LC.num_edition=PC.A06_EDITION
AND trim(LC.num_policy_x)=trim(PC.A00_PNUM)))
LEFT JOIN PROGRAM_CODE AS LPC ON lpc.G78_PROGRAM_CODE=PC.G78_PROGRAM_CODE)
LEFT JOIN BUSINESS_UNIT AS BU ON BU.R21_BUSINESS_UNIT = PC.R21_BUSINESS_UNIT WHERE LC.cde_current = 'C' AND PC.D14_Status NOT IN ('SC') GROUP BY LC.num_policy_x, LC.num_edition,
LC.cde_company,
LC.num_claim,
LC.cde_accident_state_abbr,
LC.nme_insured,
LC.dte_loss,
LC.nme_adjuster,
LC.cde_bus_unit,
LC.dte_reported,
PC.AC_FLAG,
PC.G78_PROGRAM_CODE,
LPC.G78_DESCRIPTION,
BU.R21_DESCRIPTION ORDER BY LC.cde_company,
LC.cde_bus_unit,
LC.num_claim;
I have a SQL command that works great in SQL Server. Here's the query:
SELECT TOP 1000
(
SELECT COUNT(LINENUM)
FROM OEORDD D1
WHERE D1.ORDUNIQ = OEORDD.ORDUNIQ
)
- (SELECT COUNT(LINENUM)
FROM OEORDD D1
WHERE D1.ORDUNIQ = OEORDD.ORDUNIQ
AND D1.LINENUM > OEORDD.LINENUM)
FROM OEORDD
ORDER BY ORDUNIQ, LINENUM
The query looks at the total lines on an order, then looks at the current "LINENUM" field. With the value of the LINENUM field, it looks to see how many lines have a greater LINENUM value on the order and subtracts it from the number of lines on an order to get the correct Line number.
When I try to add it as a SQL expression in version 14.0.2.364 as follows:
(
(
SELECT COUNT("OEORDD"."LINENUM")
FROM "OEORDD" "D1"
WHERE "D1"."ORDUNIQ" = "OEORDD"."ORDUNIQ"
)
- (SELECT COUNT("OEORDD"."LINENUM")
FROM "OEORDD" "D1"
WHERE "D1"."ORDUNIQ" = "OEORDD"."ORDUNIQ"
AND "D1"."LINENUM" > "OEORDD"."LINENUM"
)
)
I get the error "Column 'SAMDB.dbo.OEORDD.ORDUNIQ' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
If I try to add GROUP BY "OEORDD"."ORDUNIQ" at the end, I get "Incorrect syntax near the keyword 'GROUP'. I've tried adding "FROM OEORDD" at the end of query and it errors out on the word "FROM". I have the correct tables linked in the Database Expert.
EDIT --------------
I was able to get the first query working by getting rid of the alias, it's as follows:
(
SELECT COUNT(LINENUM)
FROM OEORDD
WHERE OEORDH.ORDUNIQ=OEORDD.ORDUNIQ)
)
However, I believe I need to use the alias in the second query to compare line numbers. I'm still stuck on that one.
I'm receiving a System.Data.SqlClient.SqlException: The server failed to resume the transaction. Desc:6c00000001 when executing a Linq-To-SQL query.
Here is my repository call:
using (var ctx = new EntitiesDataContext())
{
ctx.ObjectTrackingEnabled = false;
ctx.DeferredLoadingEnabled = false;
var loadOptions = new DataLoadOptions();
loadOptions.LoadWith<Company2QualifierLicense>(n => n.QualifierLicense);
loadOptions.LoadWith<Company2QualifierLicense>(n => n.Company);
loadOptions.LoadWith<QualifierLicense>(n => n.QualifierLicenseHoldStatus);
loadOptions.LoadWith<QualifierLicense>(n => n.LicenseTrade);
loadOptions.LoadWith<Company>(n => n.CompanyHoldStatus);
ctx.LoadOptions = loadOptions;
return ctx.Company2QualifierLicenses.Where(p => p.QualifierLicense.QualifierLicenseNumber == qualifierLicense).ToList();
}
Here is the SQL generated:
-- Region Parameters
DECLARE #p0 VarChar(1000) = '11223344'
-- EndRegion
SELECT [t0].[CompanyID], [t0].[QualifierLicenseID], [t0].[InitiatedDate], [t0].[IsActive], [t0].[RowVersion], [t0].[LastUpdated], [t1].[QualifierLicenseID] AS [QualifierLicenseID2], [t1].[QualifierLicenseNumber], [t1].[LicenseTradeID], [t1].[LicenseExpirationDate], [t1].[FirstName], [t1].[LastName], [t1].[MailingAddress1], [t1].[MailingAddress2], [t1].[City], [t1].[StateAbbr], [t1].[ZIP], [t1].[Email], [t1].[Phone], [t1].[RowVersion] AS [RowVersion2], [t1].[LastUpdated] AS [LastUpdated2], [t3].[test], [t3].[LicenseTradeID] AS [LicenseTradeID2], [t3].[LicenseCode], [t3].[LicenseDescription], [t5].[QualifierLicenseHoldStatusID], [t5].[HoldReasonID], [t5].[QualifierLicenseID] AS [QualifierLicenseID3], [t5].[RowVersion] AS [RowVersion3], [t5].[LastUpdated] AS [LastUpdated3], (
SELECT COUNT(*)
FROM [frontdesk].[QualifierLicenseHoldStatus] AS [t6]
WHERE [t6].[QualifierLicenseID] = [t1].[QualifierLicenseID]
) AS [value], [t4].[CompanyID] AS [CompanyID2], [t4].[EIN], [t4].[CompanyName], [t4].[MailingAddress1] AS [MailingAddress12], [t4].[MailingAddress2] AS [MailingAddress22], [t4].[City] AS [City2], [t4].[StateAbbr] AS [StateAbbr2], [t4].[ZIP] AS [ZIP2], [t4].[Email] AS [Email2], [t4].[Phone] AS [Phone2], [t4].[RowVersion] AS [RowVersion4], [t4].[LastUpdated] AS [LastUpdated4]
FROM [frontdesk].[Company2QualifierLicense] AS [t0]
INNER JOIN ([frontdesk].[QualifierLicense] AS [t1]
LEFT OUTER JOIN (
SELECT 1 AS [test], [t2].[LicenseTradeID], [t2].[LicenseCode], [t2].[LicenseDescription]
FROM [frontdesk].[LicenseTrade] AS [t2]
) AS [t3] ON [t3].[LicenseTradeID] = [t1].[LicenseTradeID]) ON [t1].[QualifierLicenseID] = [t0].[QualifierLicenseID]
INNER JOIN [frontdesk].[Company] AS [t4] ON [t4].[CompanyID] = [t0].[CompanyID]
LEFT OUTER JOIN [frontdesk].[QualifierLicenseHoldStatus] AS [t5] ON [t5].[QualifierLicenseID] = [t1].[QualifierLicenseID]
WHERE [t1].[QualifierLicenseNumber] = #p0
ORDER BY [t0].[CompanyID], [t0].[QualifierLicenseID], [t1].[QualifierLicenseID], [t3].[LicenseTradeID], [t5].[QualifierLicenseHoldStatusID]
GO
-- Region Parameters
DECLARE #x1 Int = 241
-- EndRegion
SELECT [t0].[CompanyHoldStatusID], [t0].[CompanyID], [t0].[HoldReasonID], [t0].[RowVersion], [t0].[LastUpdated]
FROM [frontdesk].[CompanyHoldStatus] AS [t0]
WHERE [t0].[CompanyID] = #x1
As you can see I'm creating and disposing of the DataContext immediately after the database query, so no further calls can be made from the calling method.
I see that there are two queries issued to the database and my guess is that when issuing the second query to the database the transaction has been committed, but Linq-To-SQL should be smarter than that.
I'm using .NET 4.0 and SQL Server 2008 R2 (SP1) - 10.50.2789.0
Any ideas?
UPDATE Dec/21/2011
Here is another piece of the exception:
The transaction active in this session has been committed or aborted by another session
UPDATE Dec/30/2011
A coworker found that this issue has been reported to Microsoft and it has been confirmed as a bug but it won't be fixed, and their recommendation is to move to Entity Framework.
A coworker found that this issue has been reported to Microsoft and it has been confirmed as a bug but it won't be fixed, and their recommendation is to move to Entity Framework.
A bit too long for comments.
You need to realize that eager loading in linq2sql does not work on multiple levels in a tree. So load b with a and c with b does not load a-b-c in one go.
http://www.lowendahl.net/showShout.aspx?id=190
This explains your additional second query.
Now why you get the exception I do not know.