Bug #89523 Linq query changes table name from testcasescenarios to testcasescenario1
Submitted: 4 Feb 2018 22:20 Modified: 5 Mar 2018 8:15
Reporter: Shawnik Raghav Email Updates:
Status: No Feedback Impact on me:
None 
Category:Connector / NET Severity:S1 (Critical)
Version: OS:Any
Assigned to: Assigned Account CPU Architecture:Any
Tags: asp.net, linq, MySQL, tablename

[4 Feb 2018 22:20] Shawnik Raghav
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
[5 Feb 2018 8:15] Chiranjeevi Battula
Hello Shawnik Raghav,

Thank you for the bug report.
Could you please provide repeatable test case (exact steps/sample project, MySQl, Connector / NET version, create tables statements etc. - please make it as private if you prefer) to confirm this issue at our end?

Thanks,
Chiranjeevi.
[6 Mar 2018 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".