Open
Description
I am using a custom sql table function for joins. It looks like this:
[Sql.TableFunction(Name = "somePermissionFunction")]
public ITable<EntityBase> GetPermissions(int userId, int subcatId)
{
var methodInfo = (typeof(TestDataConnection)).GetMethod("GetPermissions", new[] { typeof(int), typeof(int) });
return _dataConnection.GetTable<EntityBase>(this, methodInfo, userId, subcatId);
}
and after being used like:
var userId = 1;
var subcatId = 2;
var userId2 = 3;
var permissions = db.GetPermissions(userId, subcatId).Select(x => x.Id).Union(db.GetPermissions(userId2, subcatId).Select(x => x.Id));
var q = db.Users.Where(x => permissions.Contains(x.Id));
it's translated into the following sql:
SELECT
-- fields
FROM
[Users] [t1] WITH (NOLOCK)
WHERE
EXISTS(
SELECT
*
FROM
(
SELECT
[t2].[Id] as [Id1]
FROM
[somePermissionFunction](1, 2) [t2]
UNION
SELECT
[t3].[Id] as [Id1]
FROM
[somePermissionFunction](3, 2) [t3]
) [t5]
)
Is there a way to make those 1, 2, 3 into normal sql parameters?