Open brusw opened 7 years ago
Same problem for PostrgeSQL, i fix this by reimplementing ParseField method in IFieldParser:
public class PostgreSQLFieldParser: DefaultFieldParser
{
private readonly ISqlGenerationHelper _sqlGenerationHelper;
public PostgreSQLFieldParser(
ICurrentDbContext currentDbContext,
ISqlGenerationHelper sqlGenerationHelper,
IDbSetFinder dbSetFinder)
: base(currentDbContext, sqlGenerationHelper, dbSetFinder)
{
_sqlGenerationHelper = sqlGenerationHelper;
}
public override string ParseField(SqlFieldInfo field)
{
// just column name, without table name
return _sqlGenerationHelper.DelimitIdentifier(field.Column);
}
}
And after using this implementation instead DefaultFieldParser:
services.AddDbContext<MyDbContext>(opts =>
{
opts.UseNpgsql(Configuration.GetConnectionString("MyDatabase"));
opts.UsePostgreSQLLolita();
opts.ReplaceService<IFieldParser, PostgreSQLFieldParser>(); // replace
});
I don't know, planing some changes in this library in future...
使用
Pomelo.EntityFrameworkCore.Lolita
无法生成正确的sql更新语句: 通过GenerateBulkUpdateSql
方法查看生成的sql语句如下: