You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can't seem to find anything about table valued functions in EF core is this even possible.
Here's a sample of what I would like to achieve ...
I have a role class that looks like this ...
[Table("Roles", Schema = "Security")]
public class Role
{
[Key]
public Guid Id { get; set; }
// this is a csv list of "privilege keys" that the role grants
public string Privs { get; set; }
...
}
Add this to my DbContext ...
[DbFunction("[DMS].[GetFolderPrivList]")]
public static string[] GetFolderPrivList(string userId, Guid folderId)
{
throw new Exception();
}
Then I have a UDF like this to compute a list of privs for a folder "path" (which recursively crawls the tree for inherited permissions) ...
CREATE FUNCTION [DMS].[GetFolderPrivList]
( @UserId nvarchar(450),
@FolderId uniqueidentifier
)
RETURNS @PrivList TABLE ( priv nvarchar(100) NOT NULL)
AS
BEGIN
INSERT INTO @PrivList (priv)
SELECT DISTINCT *
FROM STRING_SPLIT((SELECT R.Privs FROM DMS.Folders P
JOIN [Security].FolderRoles PR ON FR.FolderId= P.Id
JOIN [Security].Roles R ON R.Id= FR.RoleId
JOIN [Security].UserRoles UR ON UR.RoleId = R.Id
WHERE P.Id=@FolderId AND UR.UserId=@UserId),',');
IF (SELECT ParentId FROM [DMS].[Folders] WHERE Id=@FolderId) IS NOT NULL
BEGIN
INSERT INTO @PrivList (priv)
SELECT priv
FROM [DMS].[GetFolderPrivList](@UserId,(SELECT ParentId FROM CMS.Pages WHERE Id=@FolderId))
WHERE priv NOT IN (SELECT priv FROM @PrivList)
END --*/
RETURN
END;
I can't get EF to accept this such that I can make the call in a linq query, for example ...
I can't seem to find anything about table valued functions in EF core is this even possible.
Here's a sample of what I would like to achieve ...
I have a role class that looks like this ...
Add this to my DbContext ...
Then I have a UDF like this to compute a list of privs for a folder "path" (which recursively crawls the tree for inherited permissions) ...
I can't get EF to accept this such that I can make the call in a linq query, for example ...
The text was updated successfully, but these errors were encountered: