main project - Pages/Test.razor
@page "/test"
<h3>Test</h3>
@code {
private Lazy<IJSObjectReference> _module = new();
private Lazy<IJSObjectReference> _moduleInstance = new();
private DotNetObjectReference<Test>? _reference;
[Inject]
private IJSRuntime _js { get; set; } = null!;
protected override async Task OnAfterRenderAsync( bool firstRender )
{
if( !firstRender )
{
return;
}
IJSObjectReference jsModule = await _js.InvokeAsync<IJSObjectReference>( "import", "./Pages/Test.razor.js" );
_reference = DotNetObjectReference.Create( this );
_module = new Lazy<IJSObjectReference>( jsModule );
_moduleInstance = new Lazy<IJSObjectReference>( await _module.Value.InvokeAsync<IJSObjectReference>( "GetExample" ) );
}
}
main project - Pages/Test.razor.js
class Example
{
}
let instance = new Example();
export function GetExample()
{
return instance;
}
module project - Pages/ModuleTest.razor
@page "/module/test"
@using Microsoft.JSInterop
<h3>Test</h3>
@code {
private Lazy<IJSObjectReference> _module = new();
private Lazy<IJSObjectReference> _moduleInstance = new();
private DotNetObjectReference<ModuleTest>? _reference;
[Inject]
private IJSRuntime _js { get; set; } = null!;
protected override async Task OnAfterRenderAsync( bool firstRender )
{
if( !firstRender )
{
return;
}
IJSObjectReference jsModule = await _js.InvokeAsync<IJSObjectReference>( "import", "./Pages/ModuleTest.razor.js" );
_reference = DotNetObjectReference.Create( this );
_module = new Lazy<IJSObjectReference>( jsModule );
_moduleInstance = new Lazy<IJSObjectReference>( await _module.Value.InvokeAsync<IJSObjectReference>( "GetExample" ) );
}
}
module project - Pages/ModuleTest.razor.js
class Example
{
}
let instance = new Example();
export function GetExample()
{
return instance;
}
Javascript isolation works very well ( in main/base project ) - but we cant get it to work in modules. it looks like the file is not copied to wwwroot ( this works automaticly for main/base project ) ( ref microsoft )
ok, thanks
Blazor (server) - project was created with suite 6.0.0
i belive there are two bugs that should be fixed:
AddDefaultRepository
on an entity which is part of an context with ReplaceDbContext
prevents this entity from being part of the target contextIReadOnlyRepository
in application services for entities with IMultiTenant
get the host context instead of the tenant context when they do not have a custom repositoryFound the last problem: you need a custom repository, it looks like MultiTenant doesnt work with default genrated repository
With custom repository and multi-tenant, all entities are on the same context, finally.
Found one problem: options.AddDefaultRepository<TEntity>
prevents ReplaceDbContext
to work
But ExampleEntity still in host context and user in tenant context
im not sure what you mean.
So how do i get both entities in the same context ? I thought that is the purpose of ReplaceDbContext ( tried to add IMultiTenant to exampleEntity, but same result )