Database Reference
In-Depth Information
// insert new test data
context.ExecuteStoreCommand(@"insert into
chapter9.client(Name, Email)
values ('Jerry Jones','
jjones@gmail.com
')");
}
}
}
6.
Add a Windows Console Application to the solution. This will be our test client. Use the
code shown in Listing 9-37 to implement our test client. Add a service reference to our
WCF service.
Listing 9-37.
Our Windows console application test client
using Recipe8Client.ServiceReference1;
namespace Recipe8Client
{
class Program
{
static void Main(string[] args)
{
using (var serviceClient = new Service1Client())
{
serviceClient.InsertTestRecord();
var client = serviceClient.GetClient();
Console.WriteLine("Client is: {0} at {1}",
client.Name, client.Email);
client.Name = "Alex Park";
client.Email = "
AlexP@hotmail.com
"
;
serviceClient.Update(client);
client = serviceClient.GetClient();
Console.WriteLine("Client changed to: {0} at {1}",
client.Name, client.Email);
}
}
}
}
Following is the output of our test client:
Client is: Jerry Jones at
jjones@gmail.com
Client changed to: Alex Park at
AlexP@hotmail.com
How It Works
Microsoft recommends using POCO objects with WCF to simplify serialization of the entity object. However, if your
application is using POCO objects with
changed-based notification
(you have marked properties as
virtual
and
navigation property collections are of type ICollection), then Entity Framework will create
dynamic proxies
for entities
returned from queries.