简体   繁体   English

RepoDb 似乎不适用于名称中带有点的 SQL 服务器表

[英]RepoDb does not seem to work for SQL Server tables with dot in the name

I'm starting to use RepoDb, but my SQL Server 2016 database has tables with a dot in the middle like this: User.Data .我开始使用 RepoDb,但我的 SQL Server 2016 数据库的表中间有一个点,如下所示: User.Data

Moving from full .NET Entity Framework to RepoDb, I'm facing this issue.从完整的 .NET 实体框架转移到 RepoDb,我正面临这个问题。 I'm using the fluent mapping and I wrote something like this:我正在使用流畅的映射,我写了这样的东西:

FluentMapper
    .Entity<UserData>()
    .Table("[User.Data]")
    .Primary(u => u.UserId)

I get the exception: MissingFieldsException and it says:我得到异常: MissingFieldsException并且它说:

There are no database fields found for table '[User.Data]'.没有找到表“[User.Data]”的数据库字段。 Make sure that the target table '[User.Data]' is present in the database and/or at least a single field is available.确保数据库中存在目标表“[User.Data]”和/或至少有一个字段可用。

Just for curiosity, I created a table UserData with the same attributes and primary key and it worked great (change the fluent mapper whit: .Table("[UserData]") .出于好奇,我创建了一个具有相同属性和主键的表UserData ,并且效果很好(更改流畅的映射器: .Table("[UserData]")

Am I missing something?我错过了什么吗?

Thanks for helping me谢谢你帮助我

The support to this in only available at RepoDb.SqlServer (v1.0.13) version or above.RepoDb.SqlServer (v1.0.13) 及以上版本支持。 You can use either of the approaches below.您可以使用以下任一方法。 Make sure to specify the quotes if you are using the database and schema.如果您使用的是数据库和模式,请确保指定引号。

Via built-in MapAttribute .通过内置的MapAttribute

[Map("[User.Data]")]

Via TableAttribute of the System.ComponentModel.DataAnnotations namespace.通过System.ComponentModel.DataAnnotations命名空间的TableAttribute

[Table("[User.Data]")]

Via FluentMapper as you did.像你一样通过FluentMapper

FluentMapper
    .Entity<UserData>()
    .Table("[User.Data]");

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM