dotnetcore / dotnetcore/FreeSql
WithIndex Mysql 使用问题
- Dominant language
- C#
- Stars
- 4.4k
- Forks
- 910
- PR merge metrics
- No merged PRs in 30d
Description
#### 问题描述及重现代码:
mysql下索引错误 sqlserver下是正确的 是否写法有问题?
```c#
await freeSql.Select()
.InnerJoin((a, b) => a.Id == b.Id)
.Where((a, b) => !a.DelFlag)
.WithIndex("idx_design_part_01", new Dictionary {
[typeof(MenuEntity)] = "idx_sys_menu_01"
})
.ToListAsync();
// c# code
```
mysql 下会数据库语句为
```
SELECT a.Id
FROM `design_part` a FORCE INDEX(idx_design_part_01)
INNER JOIN `sys_menu` b FORCE INDEX(idx_design_part_01) ON a.`Id` = b.`Id`
WHERE (a.`DelFlag` = 0)
```
#### 数据库版本
#### 安装的Nuget包
3.5.309
#### .net framework/. net core? 及具体版本
.net9
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reproducing the WithIndex query from the issue on MySQL and SQL Server, then compare the generated SQL, especially the FORCE INDEX clauses for DesignPartEntity and MenuEntity. Check whether the index dictionary is applied per entity as intended; done means the MySQL SQL uses the corresponding index for each joined table or the supported usage is clarified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, mysql
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100