Hi,
Enjoying a good read going through the complete example scenario in chapter 11 CREATING A SOA CASE " bit by bit. But in the "Creating Database Access for the CustomerService and the RentalService" section page 317 I get a bit confused.
Is this an error, or is it supposed to be like this. What are the overall picture of whats happening here?
In the CustomerService project I added the "LINQ to SQL Classes" (DataClassesCustomer.dbml) and dragged in the Customer table from the CarRentalCaseDB database in Server Explorer.
Fine, but when writing the code to CustomerServiceImplementation.cs I discovered that the 'Customer' class now had changed from beeing a CustomerInterface.Customer into beeing a CustomerService.Customer type.
Code:
Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
using System.Runtime.Serialization;
using CustomerInterface;
namespace CustomerService
{
public class CustomerServiceImplementation:ICustomer
{
public int RegisterCustomer(Customer customer)
// prior to creating DataClassesCustomer.dbml:
// public int RegisterCustomer(CustomerInterface.Customer customer)
//
// After creating DataClassesCustomer.dbml:
// public int RegisterCustomer(CustomerService.Customer customer)
{
Console.WriteLine("RegisterCustomer()");
using (DataClassesCustomerDataContext ctx = new DataClassesCustomerDataContext())
{
Customer customerToInsert;
customerToInsert = new Customer();
customerToInsert.CustomerName = customer.CustomerName;
customerToInsert.CustomerFirstName = customer.CustomerFirstName;
ctx.Customers.InsertOnSubmit(customerToInsert);
ctx.SubmitChanges();
return customerToInsert.CustomerID;
}
}
}
}
This does not happen in the similar creation of DataClassesRental.dbml, as the class names differ.
A Customer class is defined in the CustomerInterface project (ICustomer.cs), then used to define function parameters in the CustomerServices project (CustomerServiceImplementation.cs).
A Customer table with some identically named fields is created in the database.
Customer table is then used in the DataClassesCustomer.dbml to define a partial Customer class in the DataClassesCustomer.designer.cs file.
Which finally causes the Customer found in CustomerServiceImplementation.cs to change from beeing a CustomerInterface.Customer class to beeing a CustomerService.Customer.
Now, coincidence in this example maybe, or is this a normal happening?
Why this and are there any good guidelines/explanation on how to deal with this?
Is this an error that may cause errors in certain situations?
Hope for some good answers here:)