MyGeneration: v 1.3.0.3
EntitySpaces: v 2007.1.1210.0
Basic Information: I am using the lightweight Proxy Stub objects on the client and serializing them across web services to the server when they are de-serialized back into the heavy Proxy Stub objects, then back to the EntitySpaces objects to be saved.
Problem: Can not seem to re-build the hierarchical structure so it will save as one Hierarchical record. Not sure of the correct associatings and AttachEntity that need to be made to do this.
BASIC DATABASE STRUCTURE
CREATE TABLE [dbo].[LoanApplication](
[LoanApplication_Id] [int] IDENTITY(1,1) NOT NULL,
}
CREATE TABLE [dbo].[Applicant](
[Applicant_Id] [int] IDENTITY(1,1) NOT NULL,
[LoanApplication_Id] [int] NOT NULL,
}
CREATE TABLE [dbo].[ContactInfo](
[ContactInfo_Id] [int] IDENTITY(1,1) NOT NULL,
}
CREATE TABLE [dbo].[ApplicantContactInfo](
[Applicant_Id] [int] NOT NULL,
[ContactInfo_Id] [int] NOT NULL,
}
Seeing: The ContactInfo object is not saving in the structure. It works if I save the ContactInfo first and then save the LoanApplication object outside of a transaction.
WHAT I AM DOING CLIENT SIDE:
LoanApplicationProxyStub loanApplication = new LoanApplicationProxyStub( );
loanApplication.AppUserGUID = guid;
loanApplication.MarketId = 17;
ApplicantProxyStub applicant = new ApplicantProxyStub( );
applicant.ApplicantTypeId = 1;
applicant.FirstName = "Steve";
applicant.LastName = "Burton";
applicant.EmailAddress = "sburton@myemail.com";
ContactInfoProxyStub contactInfo = new ContactInfoProxyStub( );
contactInfo.ContactInfoTypeId = 1;
contactInfo.AreaCode = "480";
contactInfo.PhoneNumber = "5555555";
// ws is the WebService Object:
ws.CreateLoanApplication( Serializer<LoanApplicationProxyStub>( loanApplication ), Serializer<ApplicantProxyStub>( applicant ), Serializer<ContactInfoProxyStub>( contactInfo ) );
WHAT I AM DOING SERVER SIDE: (No Error Trapping Yet)
/// <summary>
/// Creates a new loan application.</summary>
/// <param name="data">Serialized data from the Ryland.OnlineLoanApplication.LoanApplication Entity object.</param>
[WebMethod]
public int CreateLoanApplication( string loanApplicationData, string applicantData, string contactInfoData )
{
LoanApplication loanApplication = ( LoanApplication )Deserializer<LoanApplicationProxyStub>( loanApplicationData );
Applicant applicant = ( Applicant )Deserializer<ApplicantProxyStub>( applicantData );
ContactInfo contactInfo = ( ContactInfo )Deserializer<ContactInfoProxyStub>( contactInfoData );
//contactInfo.Save( ); IF I DO THIS IT WORKS FINE.
loanApplication.ApplicantCollectionByLoanApplicationId.AttachEntity( applicant );
contactInfo.AssociateApplicantCollectionByApplicantContactInfo( applicant );
applicant.AssociateContactInfoCollectionByApplicantContactInfo( contactInfo );
loanApplication.Save( );
}
REASONING:
Code below casuses a failure if the ContactInfo object is not saved first (contactInfo.Save( ) ).
applicant.AssociateContactInfoCollectionByApplicantContactInfo( contactInfo );
QUESTION:
What am I missing! Do I have to build the ApplicateContactInfo with an AddNew() method. After trying this there is not way to AddEntity for the ContactInfo...
Please help Thanks.