GetRegisteredProperties and Inheritance #4180
Answered
by
rockfordlhotka
Chicagoan2016
asked this question in
Questions
-
We noticed that GetRegisteredProperties won't return properties from parent abstract object. Kind regards |
Beta Was this translation helpful? Give feedback.
Answered by
rockfordlhotka
Aug 23, 2024
Replies: 1 comment 1 reply
-
I can't reproduce your issue. I get this result:
From this code: using Csla;
using Csla.Configuration;
using Csla.Core;
using Microsoft.Extensions.DependencyInjection;
using MyCode;
var services = new ServiceCollection();
services.AddCsla();
var serviceProvider = services.BuildServiceProvider();
var portal = serviceProvider.GetRequiredService<IDataPortal<PersonEdit>>();
var person = await portal.FetchAsync(123);
foreach (var property in person.GetRegisteredProperties())
{
Console.WriteLine(property.Name);
}
namespace MyCode
{
[Serializable]
public class MyBusinessBase<T> : BusinessBase<T>
where T : MyBusinessBase<T>
{
public static readonly PropertyInfo<int> IdProperty = RegisterProperty<int>(c => c.Id);
public int Id
{
get { return GetProperty(IdProperty); }
set { SetProperty(IdProperty, value); }
}
}
[Serializable]
public class PersonEdit : MyBusinessBase<PersonEdit>
{
public static readonly PropertyInfo<string> NameProperty = RegisterProperty<string>(c => c.Name);
public string Name
{
get { return GetProperty(NameProperty); }
set { SetProperty(NameProperty, value); }
}
public List<IPropertyInfo> GetRegisteredProperties()
{
return FieldManager.GetRegisteredProperties();
}
[Fetch]
private void Fetch(int id)
{
LoadProperty(IdProperty, id);
LoadProperty(NameProperty, "Rocky Lhotka");
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Chicagoan2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I can't reproduce your issue.
I get this result:
From this code: