一、新建表值函数
TableIntSplit
二、新建类
var employees = _sqlSugarClient.Queryable<Employees>().InnerJoin(_sqlSugarClient.SqlQueryable<TableID>("select * from dbo.TableIntSplit(@ids,@split)")
.AddParameters(new { ids= "1,2", split= "," }),
(t1, t2) => t1.EmployeeID == t2.ID).ToList();
执行sql:
SELECT [t1].[EmployeeID],[t1].[LastName],[t1].[FirstName],[t1].[Title],[t1].[TitleOfCourtesy],[t1].[BirthDate],[t1].[HireDate],[t1].[Address],[t1].[City],[t1].[Region],[t1].[PostalCode],[t1].[Country],[t1].[HomePhone],[t1].[Extension],[t1].[Photo],[t1].[Notes],[t1].[ReportsTo],[t1].[PhotoPath],[t1].[Salary] FROM [Employees] [t1] Inner JOIN (select * from dbo.TableIntSplit(@ids100,@split100)) [t2] ON ( [t1].[EmployeeID] = [t2].[ID] )
运行效果: