Description:
This is my linq query
IQueryable<Scenario> scenarios = null;
scenarios = from s in Repository.Scenarios.Include(s => s.TestCaseScenario).Include(s => s.Branch).Include(s => s.TestCases)
where s.Name.Contains(q)
select s;
This linq query changes table name TestCaseScenarios to TestCaseScenario1 changing the last s to 1 for some reason.
Here is the full SQL it generates:
{SELECT
`Project2`.`Id`,
`Project2`.`AutomationStatus`,
`Project2`.`Name`,
`Project2`.`BranchId`,
`Project2`.`ScenarioTypeId`,
`Project2`.`BlockedReason`,
`Project2`.`CacheLastResults`,
`Project2`.`CacheLastResultsCount`,
`Project2`.`CacheLastResultDate`,
`Project2`.`CompressedLastPassLog`,
`Project2`.`DisplayOrder`,
`Project2`.`ScriptPath`,
`Project2`.`Id1`,
`Project2`.`Name1`,
`Project2`.`TFSLocation`,
`Project2`.`IsActive`,
`Project2`.`BootstrapperScriptId`,
`Project2`.`IsNightly`,
`Project2`.`Priority`,
`Project2`.`C1`,
`Project2`.`Id2`,
`Project2`.`CreatedAt`,
`Project2`.`UpdatedAt`,
`Project2`.`Name2`,
`Project2`.`Importance`,
`Project2`.`ReviewedBy`,
`Project2`.`Description`,
`Project2`.`Notes`,
`Project2`.`WillNotAutomate`,
`Project2`.`Origin`,
`Project2`.`ManualTestHoursTaken`
FROM (SELECT
`Limit1`.`Id`,
`Limit1`.`AutomationStatus`,
`Limit1`.`Name`,
`Limit1`.`BranchId`,
`Limit1`.`ScenarioTypeId`,
`Limit1`.`BlockedReason`,
`Limit1`.`CacheLastResults`,
`Limit1`.`CacheLastResultsCount`,
`Limit1`.`CacheLastResultDate`,
`Limit1`.`CompressedLastPassLog`,
`Limit1`.`DisplayOrder`,
`Limit1`.`ScriptPath`,
`Limit1`.`Id1`,
`Limit1`.`Name1`,
`Limit1`.`TFSLocation`,
`Limit1`.`IsActive`,
`Limit1`.`BootstrapperScriptId`,
`Limit1`.`IsNightly`,
`Limit1`.`Priority`,
`Join2`.`Id` AS `Id2`,
`Join2`.`CreatedAt`,
`Join2`.`UpdatedAt`,
`Join2`.`Name` AS `Name2`,
`Join2`.`Importance`,
`Join2`.`ReviewedBy`,
`Join2`.`Description`,
`Join2`.`Notes`,
`Join2`.`WillNotAutomate`,
`Join2`.`Origin`,
`Join2`.`ManualTestHoursTaken`,
CASE WHEN (`Join2`.`TestCase_Id` IS NULL) THEN (NULL) ELSE (1) END AS `C1`
FROM (SELECT
`Extent1`.`Id`,
`Extent1`.`AutomationStatus`,
`Extent1`.`Name`,
`Extent1`.`BranchId`,
`Extent1`.`ScenarioTypeId`,
`Extent1`.`BlockedReason`,
`Extent1`.`CacheLastResults`,
`Extent1`.`CacheLastResultsCount`,
`Extent1`.`CacheLastResultDate`,
`Extent1`.`CompressedLastPassLog`,
`Extent1`.`DisplayOrder`,
`Extent1`.`ScriptPath`,
`Extent2`.`Id` AS `Id1`,
`Extent2`.`Name` AS `Name1`,
`Extent2`.`TFSLocation`,
`Extent2`.`IsActive`,
`Extent2`.`BootstrapperScriptId`,
`Extent2`.`IsNightly`,
`Extent2`.`Priority`
FROM `Scenarios` AS `Extent1` INNER JOIN `Branches` AS `Extent2` ON `Extent1`.`BranchId` = `Extent2`.`Id`
WHERE `Extent1`.`Name` LIKE @p__linq__0 LIMIT 200) AS `Limit1` LEFT OUTER JOIN (SELECT
`Extent3`.`TestCase_Id`,
`Extent3`.`Scenario_Id`,
`Extent4`.`Id`,
`Extent4`.`CreatedAt`,
`Extent4`.`UpdatedAt`,
`Extent4`.`Name`,
`Extent4`.`Importance`,
`Extent4`.`ReviewedBy`,
`Extent4`.`Description`,
`Extent4`.`Notes`,
`Extent4`.`WillNotAutomate`,
`Extent4`.`Origin`,
`Extent4`.`ManualTestHoursTaken`
FROM `TestCaseScenario1` AS `Extent3` INNER JOIN `TestCases` AS `Extent4` ON `Extent4`.`Id` = `Extent3`.`TestCase_Id`) AS `Join2` ON `Limit1`.`Id` = `Join2`.`Scenario_Id`) AS `Project2`
ORDER BY
`Project2`.`Id` ASC,
`Project2`.`Id1` ASC,
`Project2`.`C1` ASC}
How to repeat:
Create the same linq query.
Suggested fix:
Change table name to testcasescenarios