Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TableInfo中的IsAutoIncrementPrimary的逻辑是不是有问题? #83

Closed
sanjusss opened this issue Nov 14, 2018 · 1 comment
Closed
Assignees
Labels

Comments

@sanjusss
Copy link
Contributor

TableInfo中:

internal bool IsAutoIncrementPrimary => Primary.Count == 1 && Columns.Count(f => f.DataType == DataType.Int || f.DataType == DataType.Long) == 1;

判定数据库表是否应使用自增主键,当前逻辑为:

如果只有一个主键,且表中整型变量数量为1,那么这个主键就是自增的。
存在以下问题:

  • 当使用者不需要自增主键时,是否应强制指定?
  • 如果我只有一个string类型的主键,还需要设置自增吗?(mysql直接报错)
    明显原本设计意图是只有一个主键且主键为整型时,设置自增。
zlzforever added a commit that referenced this issue Nov 14, 2018
@zlzforever
Copy link
Collaborator

已经修复。
如果不需要自增主键,自行继承IBaseEntity即可
如果你只需要一个string主键,继承 IBaseEntity, 然后自己设置属性[Primary], 因为类型是 string, 因此不会设置为自增主键。

@zlzforever zlzforever added the bug label Nov 14, 2018
@zlzforever zlzforever self-assigned this Nov 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants