Yeah I asked him it was working on his machine but not mine 🤔, we checked the same commit.
Hi, I sent it through your email.
Hi,
I did not change the generated client proxy's namespace.
Hi, I tried again just now, it's still showing the same error.
abp generate-proxy -t csharp -u https://localhost:44395/ -m globalService
The API description of the CmvPoint.GlobalService.Controllers.IDataReferenceAppService.GetNextReferenceIdAsync method was not found!
Even trying to change the configuration on the client module using AddStaticHttpClientProxies
and AddHttpClientProxies
isn't working.
ABP Framework version: v7.0.1
UI type: Blazor Server
DB provider: EF Core
Project Template: Microservice
Steps to reproduce the issue:"
Exception message and stack trace: [08:14:01 FTL] Dummy.AdministrationService.HttpApi.Host terminated unexpectedly! System.IO.FileNotFoundException: Could not load file or assembly 'Volo.Abp.Commercial.SuiteTemplates, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
File name: 'Volo.Abp.Commercial.SuiteTemplates, Version=7.0.1.0, Culture=neutral, PublicKeyToken=null'
public interface IReferenceObject{
string ReferenceId {get;}
}
public class Book : FullAuditedAggregateRoot<Guid>, IReferenceObject{
public Book(Guid id, string referenceId){
Id = id;
ReferenceId = referenceId;
}
public string ReferenceId { get; }
public string Title { get; set; }
}
My goal is to subscribe on create event to every entities that inherits the IReferenceObject
.
I read the documentation here https://docs.abp.io/en/abp/latest/Local-Event-Bus#pre-built-events and tried this:
public class ReferenceObjectEventHandler : ILocalEventHandler<EntityCreatedEventData<IReferenceObject>>, ITransientDependency
{
public async Task HandleEventAsync(EntityCreatedEventData<IReferenceObject> eventData)
{
Console.WriteLine($"Created an entity with reference id {eventData.Entity.ReferenceId}");
}
}
But it's not working..any suggestion?
Hi, you can try this:
Install the DevExpress.Xpo.EFCore NuGet package in your project. Create a class that inherits from the DevExpress.Xpo.XpoDbContext base class, this class represents the database context.
public class MyDbContext : XpoDbContext
{
public MyDbContext(DbContextOptions<MyDbContext> options)
: base(options)
{
}
}
Create entity:
[Persistent("MyEntity")]
public class MyEntity : XPLiteObject
{
[Key]
[Persistent("MyId")]
public int MyId { get; set; }
[Persistent("MyProperty")]
public string MyProperty { get; set; }
}
If your model has relationship you can refer to this article: https://docs.devexpress.com/eXpressAppFramework/402958/business-model-design-orm/business-model-design-with-entity-framework-core/relationships-between-entities-in-code-and-ui
Register the dbcontext and XpoDbContextOption in your module and define your custom repository:
public interface IMyEntityRepository: IRepository<MyEntity >
{
Task<List<MyEntity>> GetListAsync(
string filterText = null,
string sorting = null,
int maxResultCount = int.MaxValue,
int skipCount = 0,
CancellationToken cancellationToken = default);
}
public class MyEntityRepository: EfCoreRepository<MyDbContext, MyEntity >, IMyEntityRepository
{
public async Task<List<MyEntity>> GetListAsync(string filterText = null, string sorting = null,
int maxResultCount = int.MaxValue, int skipCount = 0, CancellationToken cancellationToken = default)
{
var query = await GetQueryableAsync();
query = query
.WhereIf(filterText != null, d => d.Name.Contains(filterText))
.OrderBy(string.IsNullOrWhiteSpace(sorting) ? MyEntityConsts.GetDefaultSorting(false) : sorting);
return await query.PageBy(skipCount, maxResultCount).ToListAsync(cancellationToken);
}
}
[DependsOn(typeof(AbpEfCoreModule))]
public class MyModule : AbpModule
{
public override void ConfigureServices(ServiceConfigurationContext context)
{
context.Services.AddAbpDbContext<MyDbContext>(options =>
{
options.AddDefaultRepositories();
options.AddRepository<IMyEntityRepository, MyEntityRepository>();
});
}
}
In your application service module you can:
public class MyService : ApplicationService
{
private readonly IMyEntityRepository _myEntityRepository;
public MyService(IMyEntityRepository myEntityRepository)
{
_myEntityRepository = myEntityRepository;
}
public async Task<MyEntity> GetAsync(int id)
{
return await _myEntityRepository.FirstOrDefaultAsync(x => x.MyId == id);
}
}