-
Notifications
You must be signed in to change notification settings - Fork 133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fluent API: support like EF IEntityTypeConfiguration for seperate domain entity #14
Comments
Fluent API is already supported: #4 (comment) |
I know Fluent API is supported already. |
I have also looked into the pull request, I want similar that kind of approach, but not in controller. |
I am asking for such functionality. |
This is just suggestion, |
What if you create multiple subclasses with different fluent APIs then use something like DI to choose the one you want to be used? |
It will be great if you can give me an example code. |
any update? |
Sorr for the delay - I meant creating multiple subclasses of |
then how to register 'SieveProcessor'? |
Basically I want new change in core functionality, Hope you understand my requirement. |
please do the needful. |
Creating multiple subclasses looks like: public class ApplicationSieveProcessorOne : SieveProcessor
{
public ApplicationSieveProcessor(
IOptions<SieveOptions> options,
ISieveCustomSortMethods customSortMethods,
ISieveCustomFilterMethods customFilterMethods)
: base(options, customSortMethods, customFilterMethods)
{
}
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
{
//mapper details from issue #4
}
} and another one public class ApplicationSieveProcessorTwo : SieveProcessor
{
public ApplicationSieveProcessor(
IOptions<SieveOptions> options,
ISieveCustomSortMethods customSortMethods,
ISieveCustomFilterMethods customFilterMethods)
: base(options, customSortMethods, customFilterMethods)
{
}
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
{
//DIFFERENT mapper details from issue #4
}
} Now just use whichever class you want. I'm not really sure why this wouldn't work for ya. Are you using it with ASP.NET Core and the default DI? If so, you can easily inject whichever class you want in Startup.cs. |
I dont aggree with you @Biarity this is very inefective. EF Core enables us to use builder from our models without any other setup you just need to implement interface. This should't be that hard to implement since you already have SieveProcessor. If you would like i can make a pull request but only if you are interested in such a feature :) |
For now i use something like this public class MyEntity : ISieveConfiguration
{
public string Name { get; set; }
public void ConfigureSieve(SievePropertyMapper mapper)
{
mapper.Property<Regatta>(p => p.Name)
.CanFilter();
}
}
public interface ISieveConfiguration
{
public void ConfigureSieve(SievePropertyMapper mapper);
}
public class CustomSieveProcessor : SieveProcessor
{
public CustomSieveProcessor(
IOptions<SieveOptions> options)
: base(options)
{
}
protected override SievePropertyMapper MapProperties(SievePropertyMapper mapper)
{
Assembly
.GetExecutingAssembly()
.GetTypes()
.Where(m => m.GetInterfaces().Any(i => i == typeof(ISieveConfiguration)))
.ToList()
.ForEach(m =>
{
var instance = Activator.CreateInstance(m);
m.GetMethod("ConfigureSieve").Invoke(m, new object[] { mapper });
});
return mapper;
}
} |
I do not want to change the domain entities using a decorator.
I want something like this,
The text was updated successfully, but these errors were encountered: