- Lambda expressions
- Property dependencies autodetection
- Sub-object property configurations
- Async attribute values support
- WebApi endpoint ready
public class MyClassConfig : TypeConfig<MyClass>
{
public MyClassConfig()
{
Property(x => x.SomeProp1)
.Attribute("static_attr")
.Attribute("expression_attr", x => x.Entity.SomeProp2 > 0)
.Attribute("value_attr", x => 100 * x.Entity.SomeProp3)
.Attribute("task_value_attr", x => x.ServiceProvider.GetRequiredService<MyService>().AsyncMethod(x.CancellationToken));
Property(x => x.ComplexProp.SubProp1)
.Required(x => x.Entity.SomeProp2 > 0)
.Hidden(x => !x.Entity.SomeProp3);
}
}
using EntityDynamicAttributes;
builder.Services.AddEntityDynamicAttributes(typeof(MyClassConfig).Assembly);
var schema = await services.GetRequiredService<ISchemaBuilder<MyClass>>()
.Build(new MyClass());