migomiddle / xms

基于.netcore的跨平台应用框架,包含众多常用模块,易上手、易扩展,xms可理解为x(可扩展的/任意的)m(管理)s(系统)
https://www.cnblogs.com/migomiddle
MIT License
480 stars 159 forks source link

用户管理查询 查询未指定角色的用户时出现无法绑定由多个部分组成的标识符 "[lk_SystemUserRoles_SystemUserId.systemuserid] #10

Open felixsuccess opened 4 years ago

felixsuccess commented 4 years ago

用户管理查询 查询未指定角色的用户时出现 string 无法绑定由多个部分组成的标识符 "[lk_SystemUserRoles_SystemUserId.systemuserid] IS NULL AND [systemuser.statecode"。: SELECT COUNT(*) FROM [systemuserView] AS [systemuser] WITH(NOLOCK) LEFT JOIN [systemuserrolesView] AS [lk_SystemUserRoles_SystemUserId] WITH(NOLOCK) ON [lk_SystemUserRoles_SystemUserId].[systemuserid] = [systemuser].[systemuserid] WHERE ( [[lk_SystemUserRoles_SystemUserId].[systemuserid]] IS NULL AND [systemuser].[statecode]=@0 ) ;

felixsuccess commented 4 years ago

方案1 ,将 PocoHelper.cs 中的 WrapName方法修改如下。 public static string WrapName(string name) { var dbType = "mssql";// XmsApplication.Configuration["database:dbtype"]; // return dbType.IsCaseInsensitiveEqual("mssql") ? "[{0}]".FormatWith(name) : name; if (dbType.IsCaseInsensitiveEqual("mssql")) { if (name.IndexOf(".")<0) { return "[{0}]".FormatWith(name); } else { return "[{0}]".FormatWith(name).Replace(".","].["); } } else { return name; }

    }
felixsuccess commented 4 years ago

在Xms.Sdk.Data的QueryExpressionResolver 中的 makeCondition 中关于attrName赋值部门修改为下方代码 private string MakeCondition(Schema.Domain.Entity entityMetaData, string entityAliaName, ConditionExpression conditionNode) { string condition = string.Empty; //下方一句为 原来代码 // string attrName = (conditionNode.AttributeName.IndexOf('.') < 0 ? PocoHelper.WrapName(entityAliaName) + "." : "") + PocoHelper.WrapName(conditionNode.AttributeName);

        //下方为修改后的代码
         string  attrName = string.Empty;

       if (conditionNode.AttributeName.IndexOf('.') < 0)
      {
           attrName = PocoHelper.WrapName(entityAliaName) + "." + PocoHelper.WrapName(conditionNode.AttributeName);
      }
        else {
            attrName = conditionNode.AttributeName;
       }

// 以上为修改后的代码