locked
Problem Ria Services - Insert RRS feed

  • Question

  • Hello my friends,

    I have a problem in my application, the scenario it's:

    I have a domain service exposing the entity tbmServidor, and in other DomainService i have a entity tbsCliente.

    In my medatadaclass tbmServidor, I have a propertie using AddReference to association with other domain:

                [ExternalReference]
    [Association("tbmServidor_tbsPessoaFisica", "intPessoaFisica", "intPessoaFisica", IsForeignKey = true)]
    public tbs_PessoaFisica tbs_PessoaFisica { get; set; }
    Ok... it's work ok when I add reference in my client silverlight appliucation and update data of tbmServidor, all work ok. 
    But the problem is when i try add a new tbmServidor.. the tbsCliente type don't work and every is null.
    
    
    What's problem?
    
    
    Thanks
    
    
    
    
    Thursday, October 20, 2011 9:01 PM

Answers

  • Hmmm, did you mark your navigation property to be included?

    In your service.metadata file add a [Include] attribute above the navigation property like so:

    [Include]
                public EntityCollection<SomeEntity> SomeCollection { get; set; }
     
    Then in your service also make sure to include that collection like so:
    objectContext.SomeModel.Include("SomeCollection")
    Tuesday, October 25, 2011 3:44 AM

All replies

  • Nobody can help´-me?

    Friday, October 21, 2011 1:55 PM
  • Hi Carlos,

    According to you discription, below is a link on sharing entities between multiple Domain which includes a walkthrough that displays data from two entities in two separate entity models and domain services. You may take a look.

    http://msdn.microsoft.com/en-us/library/ff422034(v=vs.91).aspx

    Best Regards,

    Monday, October 24, 2011 4:12 AM
    Moderator
  • Hello friend... thank you about response.

    I saw the link before the post a question... but that example is very simple. My situation is similar, but the problem is that:

    I have a DomainService exposing tbmServidor... that have a tbsCliente property with ExternalReference attribute

    I have too DomainService exposing tbsCliente... and in my client i do:

    DomainServicetbmServidor.addreferece(typeof(tbsCliente), mydomainservicetbmservidor);

    But tbsCliente have properties refering to another domain service, exemplo:

    tbsLogradouro that exposed by DomainserviceAuxiliar.. 

    The fact is to show data, working perfect, but when i try Add new tbmServidor using:

    tbmServidor _tbmServidor = new tbmServidor();

    DomainDataSourceTbmServidor.DataView.Add(_tbmServidor);

    The property tbsCliente every is null... this is problem :(

    Monday, October 24, 2011 8:54 AM
  • Hi Carlos,

    Not sure if this will be of any help, but you need to treat your Ria objects as objects that reference the parent.

    So as an example,

    1. You get a list of Countries from your RIA service.
    2. Your country then have a property of the list of provinces/states so lets call it States. This property exists since you associated your Country to your Provinces in your RIA model.
    3. Then to add a new State you will do something like this Country.States.Add(new State {"HAWAII"})
    4. Your DomainContext will then be true for the property HasChanges.
    5. So to submit and save it, just call MyDomainContext.SubmitChanges().

     

     

    Monday, October 24, 2011 10:16 AM
  • Hello esite... thank for help..

    But a problem is that a have a Navigation Propertie in tbmServidor.. with tbsCliente to target... I haven't tbsClientes in my tbmServidor class. 

    I can't understand why tbsCliente in tbmServidor is null when i try to add new item...

    If my DomainContext that expose tbmServidor have a reference to DomainContext that expose tbsCliente.

    :(

    Monday, October 24, 2011 5:44 PM
  • Hmmm, did you mark your navigation property to be included?

    In your service.metadata file add a [Include] attribute above the navigation property like so:

    [Include]
                public EntityCollection<SomeEntity> SomeCollection { get; set; }
     
    Then in your service also make sure to include that collection like so:
    objectContext.SomeModel.Include("SomeCollection")
    Tuesday, October 25, 2011 3:44 AM