dotnetcore / dotnetcore/FreeSql

UseNameConvert(FreeSql.Internal.NameConvertType.PascalCaseToUnderscoreWithLower)在Ado时失效

Open
#2,249 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
4.4k
Forks
910
PR merge metrics
No merged PRs in 30d

Description

#### 问题描述及重现代码:
在构建时使用`UseNameConvert(FreeSql.Internal.NameConvertType.PascalCaseToUnderscoreWithLower)`,致使该规则的列至对象属性的映射和[Column(Name="xx_yy")]约定的映射规则在Ado执行sql语句时双双失效,不过,ISelect查询时的对象映射仍是正常的。
```c#
// c# code
IFreeSql fsq = new FreeSqlBuilder().UseConnectionString(DataType.Sqlite, @"Data Source=data.db")
.UseNameConvert(FreeSql.Internal.NameConvertType.PascalCaseToUnderscoreWithLower)
.Build();

class Resources
{
[Column(Name = "id", IsPrimary = true, IsIdentity = true)]
public int Id { get; set; }
[Column(Name = "tid")]
public int Tid { get; set; }
//[Column(Name ="resource_type")] //--case 1
public string ResourceType { get; set; }
[Column(Name = "resource_value")] //--case2
public string ResourceValue { get; set; }
//[Column(Name = "resource_value")] // valid case
//public string Resource_Value { get; set; }
[Column(Name = "created_at")]
public DateTime CreatedAt { get; set; }
}

var res = fsq.Ado.Query("select * from resources");
//以上只能接收到无下划线的列,如id,tid,当泛型类型是dynamic时,名称为数据库中的列名,值可以正常接收
```
``` sql
CREATE TABLE resources (
id INTEGER PRIMARY KEY AUTOINCREMENT,
tid INTEGER NOT NULL,
resource_type TEXT NOT NULL,
resource_value TEXT NOT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
```
#### 数据库版本
SQLite version 3.50.2

#### 安装的Nuget包

#### .net framework/. net core? 及具体版本
net10.0

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the provided SQLite reproduction using UseNameConvert and Ado.Query, comparing it with the working ISelect mapping and dynamic results. Trace how Ado maps query columns to Resources properties, including Column(Name=...) attributes. Done means resource_type, resource_value, and created_at map correctly while preserving the existing valid cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sqlite
Domain
database
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.