Replies: 3 comments 8 replies
-
@KimBon Thanks for a concise write up of your askes :) Short answer is "yes" this is possible, and we have designed the system to support this type of development. It's not necessary to target .net standard for any of this. .net framework is fully backward compatible, targeting .net 4.6.2 will create libs that are usable on .net 4.6.2 and .net 4.8. You can use Earlybound classes in both plugins and clients. Your common 'shared' code should aways use IOrganizationService for access to Dataverse itself, the client and server clients are derived from that. |
Beta Was this translation helpful? Give feedback.
-
@MattB-msft thanks for your feedback You mean that the shared lib can use .net framework 4.6.2, so can work in plugins and can be used in .net 8 since .net 8 is backward compatible and supports net462 libs? Should the project have multiple target frameworks (TFM)? I now tested with a .NET Standard 2 library, using an IsExternalInit class to force for c# 11 (similar to this stackoverflow thread) Not sure this is a good idea and supported by MS for plugins. I can share a Poc with you if useful If the shared code were to use IOrganizationService, can the service be a singleton in the .net 8 app? Or should it be cloned for each request scope? If used in plugins, supporting IOrganizationSerivce alone would not suffice, as the plugin can use the target or pre/post images too?:
|
Beta Was this translation helpful? Give feedback.
-
Targeting .net 462 for your shared libraries will provide maximum compatibility. .net 462 compiled code will work properly in .net 48, Lang version is a separate from framework version and has to do with which version of the dotnet SDK you're using to do compilation. see: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/configure-language-version .net standard in general has been set aside in favor of newer concepts in .net 5+ .. you can read more on that here: https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-1-0 Were it me, (and this is my opinion only) I would not mess with .net standard and just multi-target if needed. In Plugins, IOrganizationService is what you get from the OrganizationServiceFactory type: OrgSvcFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
CurrentUserService = OrgSvcFactory.CreateOrganizationService(PluginExecutionContext.UserId); In this case 'CurrentUserService' is an IOrganizationService. Both Pre and Post images return 'Entity' types. Your shared library should accept an Ilogger for logging, and if you wanted to do data ops from within it, accept an IOrganizationService. MattB |
Beta Was this translation helpful? Give feedback.
-
Hi
Wondering whether it is possible to develop a joint business logic layer that can be consumed by plugins on net framework 462 and .net8 .
I have been looking to former threads, but Im not sure if I understand well and if they are still relevant:
#15
In a simple setup, there would be business layer consisting of:
This layer would be .net standard 2 so that they can be shared.
Plugins or the web app have to make sure they fetch the data and update the output.
Plugins will do that either via organization service or the plugincontext.targetentity (pre operation).
The web app will do that with the new dataverse client.
Downside of this is that both will have very similar logic for their data access logic.
Based on this idea, I would like to validate some assumptions:
Are there any alternatives to this approach?
What is on the roadmap in bringing some clarity for this topic?
What is the way forward looking at further support in the future?
cc @MattB-msft @JimDaly
Beta Was this translation helpful? Give feedback.
All reactions