0

我有以下(简化的)数据库设计:

  • 目的
  • 用户权限
  • 组权

基本上我想设置UserRights和/或GroupRights打开Objects. UserRights应该比 强GroupRights。换句话说:如果UserRight设置了 a ,则GroupRights忽略 。

我已经用 SQL 视图和一个存储过程解决了这个问题,但我不能在 C# 中使用结果。

存储过程如下所示,添加到 Visual Studio 2010 的 EDMX 文件中。

<Function Name="UDF_GetAuthorizedObjects" Aggregate="false" BuiltIn="false" NiladicFunction="false" IsComposable="false" ParameterTypeSemantics="AllowImplicitConversion" Schema="dbo">
    <CommandText>
        select * from Objects
        where exists (select * from V_GetEffectiveObjectRights where 
        UserId = @userId and RightValue = @neededRightId and Objects.Id = ObjectId)
    </CommandText>
    <Parameter Name="userId" Type="int"></Parameter>
    <Parameter Name="neededRightId" Type="int"></Parameter>
</Function>

功能导入:

<FunctionImport Name="GetAuthorizedObjects" EntitySet="Objects" ReturnType="Collection(DAL.Object)">
    <Parameter Name="userId" Type="Int32" Mode="In" />
    <Parameter Name="neededRightId" Type="Int32" Mode="In" />
</FunctionImport>

函数导入映射:

<FunctionImportMapping FunctionImportName="GetAuthorizedObjects" FunctionName="VSD.Core.DAL.Store.UDF_GetAuthorizedObjects" />

我得到的是以下错误消息:

函数“GetAuthorizedObjects”的返回类型“DAL.Object”是抽象的,不能隐式映射。

如果无法使用存储过程的方法,是否有人建议如何以不同的方式解决问题?

4

0 回答 0