私は次の(簡略化された)DB設計を持っています:
- 物体
- UserRight
- GroupRight
基本的に私は設定UserRights
および/またはGroupRights
オンにしたいですObjects
。UserRights
よりも強力である必要がありGroupRights
ます。つまり、aUserRight
が設定されている場合、GroupRights
は無視されます。
SQLビューと1つのストアドプロシージャでこれを解決しましたが、結果をC#で使用できません。
ストアドプロシージャは次のようになり、VisualStudio2010の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:
<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:
<FunctionImportMapping FunctionImportName="GetAuthorizedObjects" FunctionName="VSD.Core.DAL.Store.UDF_GetAuthorizedObjects" />
次のエラーメッセージが表示されます。
関数「GetAuthorizedObjects」の戻りタイプ「DAL.Object」は抽象であり、暗黙的にマップすることはできません。
ストアドプロシージャを使用したアプローチが不可能な場合に、問題を別の方法で解決する方法について誰かが提案していますか?