生成执行sql时,什么情况下变量没有被替换成对应的值? 返回

错误信息:必须声明标量变量 "@p0_101"。
var Sku_2_SelectModel = new SelectModel { FieldName = ObjectFuncModel.Create("IsNull", "A.DDFMID", "{string}:"), AsName = "DDFMID" };
热忱回答(8)
-
fate sta VIP0
1周前0 回复 -
fate sta VIP0
1周前sqlsugar如果版本低升级最新
0 回复 -
zyq VIP0
1周前private readonly SqlSugarRepository<DrSysCode> drSysCode;
drSysCode.Delete(x => x.TypeId == code.codeId);
输出sql:
DELETE FROM "DR_SYS_CODE" WHERE ( "TYPE_ID" = :TypeId0 ) 我的也会出现同样问题
sqlsugar 为最新版
UtilMethods.GetSqlString(c.DbType, sql, pars); 用这种方式获取的sql
0 回复 -
fate sta VIP0
1周前@zyq:sqlsugar版本号多少
0 回复 -
zyq VIP0
1周前@fate sta:5.1.4.182
0 回复 -
fate sta VIP0
1周前没有重现你的问题下面我写的DEMO
var xxx= db.Deleteable<xxxx>().Where(it => it.TypeId == "as").ToSql(); var xxxx= UtilMethods.GetSqlString(DbType.Oracle, xxx.Key, xxx.Value.ToArray()) public class xxxx { [SugarColumn(ColumnDataType ="Type_Id")] public string TypeId { get; set; } }
断点结果
0 回复 -
fate sta VIP0
1周前提供完整DEMO不然浪费的还是你的时间
0 回复 -
zyq VIP0
1周前@fate sta:
public class DrSysCodeConfigService : ITransient
{
//日志注解
public readonly ILogger<DrSysCodeConfigService> Logger;
//数据库访问
private readonly SqlSugarRepository<DrSysCodeConfig> Db;
private readonly SqlSugarRepository<DrSysCode> drSysCode;
public DrSysCodeConfigService(ILogger<DrSysCodeConfigService> _Logger,
SqlSugarRepository<DrSysCodeConfig> _Db,
SqlSugarRepository<DrSysCode> _drSysCode)
{
Logger = _Logger;
Db = _Db;
drSysCode = _drSysCode;
}
public bool delData(DrSysCodeConfig code)
{
sysCacheService.DelAsync(cacheKey);
//级联删除
drSysCode.Delete(x => x.TypeId == code.codeId);
return Db.Context.Deleteable(code).ExecuteCommand() > 0;
}
}
services.SqlSugarScopeConfigure();
public static void SqlSugarScopeConfigure(this IServiceCollection services)
{
。。。。其他代码
services.AddSingleton<ISqlSugarClient>(sqlSugarScope);
// 注册 SqlSugar 仓储
services.AddScoped(typeof(SqlSugarRepository<>));
}
0 回复