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

CodeFirst 中 char 类型如何处理? #235

Closed
guliang21 opened this issue Mar 17, 2020 · 5 comments
Closed

CodeFirst 中 char 类型如何处理? #235

guliang21 opened this issue Mar 17, 2020 · 5 comments

Comments

@guliang21
Copy link

实体属性类型为 char 时,貌似会被忽略掉。试了多种方式都没成功

@2881099
Copy link
Collaborator

2881099 commented Mar 17, 2020

[Column(DbType = “char”)]

@guliang21
Copy link
Author

我试出来了。要 [Column(MapType = typeof(string), DbType = "char")] 才行。为什么是 MapType = typeof(string) 呢?

@2881099
Copy link
Collaborator

2881099 commented Mar 17, 2020

你的类型用的 char[] 吗,wiki 里面有映射文档表

@guliang21
Copy link
Author

不,我实体类型是 char,数据库的类型希望是 char(1),我是 SqlServer 数据库

@guliang21
Copy link
Author

实体属性类型 char,不能直接映射到数据库的 char(1)。我也理解了需要用 MapType = typeof(string) 的用意。

如果可以直接映射,应该会更好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants