CSLA 6: Unable to use csla objects in static ObjectAuthorizationRules method #2790
Replies: 6 comments 7 replies
-
Which type of app are you building? There are some workarounds for winforms/wpf/uwp. If you are in aspnetcore/blazor there are less easy workarounds. |
Beta Was this translation helpful? Give feedback.
-
In Blazor, the most direct solution is to inject an @inject IDataPortalFactory factory;
@code
{
public async void MyAsyncMethod()
{
var obj = await MyType.GetMyType(factory, 123);
}
} then [Serializable]
public class MyType : BusinessBase<MyType>
{
public static async Task<MyType> GetMyType(IDataPortalFactory factory, int id)
{
return await factory.GetPortal<MyType>().FetchAsync(id);
}
} |
Beta Was this translation helpful? Give feedback.
-
Thanks Rocky, I thought that it would not be possible to access the services from the static method. I am hopeful that it will be possible to provide services to the AddObjectAuthorizationRules method. |
Beta Was this translation helpful? Give feedback.
-
Ongoing discussion in #2796 - @JacoJordaan your input will be valuable. |
Beta Was this translation helpful? Give feedback.
-
following is working solution that is working in my environment public static void AddObjectAuthorizationRules([Inject] AddObjectAuthorizationRulesContext authContext)
} |
Beta Was this translation helpful? Give feedback.
-
and here is my TableRightsList Businesss List Class using System; namespace Security.Library
} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
In my CSLA 4/5 classes I have been adding object type rules from data retrieved from the database.
The static
AddObjectAuthorizationRules
method calls relevant csla objects to retrieve the required permission data from the database. It then constructs and adds the authorisation business rules.In CSLA 6 you can't create csla objects from a static class. How would this be accomplished in CSLA 6?
If I was able to reference the DataPortal from the static class then this should be possible.
Or if it was in some way possible to reference the service provider then I can call the relevant csla factory classes.
Any ideas?
Beta Was this translation helpful? Give feedback.
All reactions