Skip to content
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

Add an IEntityTypeConfiguration equivalent for nested Owned Type #19904

Closed
MiguelEncarnacao opened this issue Feb 13, 2020 · 2 comments
Closed
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@MiguelEncarnacao
Copy link

MiguelEncarnacao commented Feb 13, 2020

Hi,
I implemented the following classes:

public class Documento : Entity
    {               
        public string Serie { get; private set; }   
        public DocumentoDados Dados { get; private set; }
   }
 public class DocumentoDados : ValueObject
    {
        public int DocumentoId { get; set; }       
        public Morada ClienteMorada { get; set; }
        public string EmissorDesignacao { get; set; }
        public Morada EmissorMorada { get; set; }
    }
 public class Morada : ValueObject
    {       
        public string Rua { get;  set; }        
        public string Numero { get;  set; }       
        public string CodigoPostal { get;  set; }       
        public string Localidade { get;  set; }
    }

Using the proposal @AndriySvyryd made on issue #15681 proposal I'm able to configure my OwnedEntities, but I can't seem to Create a Configuration for the nested Owned Type "Morada" within "DocumentoDados" on the "Documento" Entity.

Has anyone come across this before?

@AdrianoAE-Surface
Copy link

Hello,

You can add the following extension method

public static OwnedNavigationBuilder<TEntity, TNewDependentEntity> ApplyOwnsOneConfiguration<TEntity, TNewDependentEntity, TOwnedEntity>(
    this OwnedNavigationBuilder<TEntity, TNewDependentEntity> entityTypeBuilder,
    Expression<Func<TNewDependentEntity, TOwnedEntity>> navigationExpression,
    IOwnedNavigationConfiguration<TNewDependentEntity, TOwnedEntity> configuration)
    where TEntity : class
    where TNewDependentEntity : class
    where TOwnedEntity : class
{
    entityTypeBuilder.OwnsOne(navigationExpression, configuration.Configure);
    return entityTypeBuilder;
}

@MiguelEncarnacao
Copy link
Author

Hello,

You can add the following extension method

public static OwnedNavigationBuilder<TEntity, TNewDependentEntity> ApplyOwnsOneConfiguration<TEntity, TNewDependentEntity, TOwnedEntity>(
    this OwnedNavigationBuilder<TEntity, TNewDependentEntity> entityTypeBuilder,
    Expression<Func<TNewDependentEntity, TOwnedEntity>> navigationExpression,
    IOwnedNavigationConfiguration<TNewDependentEntity, TOwnedEntity> configuration)
    where TEntity : class
    where TNewDependentEntity : class
    where TOwnedEntity : class
{
    entityTypeBuilder.OwnsOne(navigationExpression, configuration.Configure);
    return entityTypeBuilder;
}

Thanks, worked like a charm!

@ajcvickers ajcvickers added the closed-no-further-action The issue is closed and no further action is planned. label Feb 15, 2020
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

3 participants