当前位置: 首页 > 工具软件 > FreeSQL > 使用案例 >

freesql自定义sql和参数查询

秦禄
2023-12-01

    public CommonResult Get(string model)
        {
            CommonResult commonResult = new CommonResult();
            SqlParameter[] sqlParameters = new SqlParameter[]
            {
            new SqlParameter("@FModel", $"%{model}%")
            };
            string sql = @" 
            Select t1.FNumber as FMaterialNumber,t1.FName as FMaterialName,
            t6.FName as FAuxPropName,t1.FModel as FMaterialMode,u1.FQty
            From  ICInventory u1 
            left join t_ICItem t1 on u1.FItemID = t1.FItemID
            left join t_AuxItem t6 on u1.FAuxPropID=t6.FItemID
            left join t_MeasureUnit t7 on t1.FSecUnitID=t7.FItemID Where u1.FQty <> 0 
            AND  t1.FModel like @FModel";
            List<StockData> stockDatas = FreeSqlHelper.Fsql.
                Select<StockData>().
                WithSql(sql, new { FModel = $"%{model}%" }).ToList();
            commonResult.data = stockDatas;
            return commonResult;
        }

 类似资料: