A couple more "tit-bits" that dropped out whilst playing with the March CTP. It seems that unlike in this previous post which was based on much earlier CTP's I can now have something like;
[StoredProcedure(Name = "dbo.GetCustomersByCountry")]
public IEnumerable<Customer> GetCustomersByCountry(
[Parameter(Name = "@country")] string country)
{
IQueryResults<Customer> result =
this.ExecuteMethodCall<Customer>(
this,
((MethodInfo)(MethodInfo.GetCurrentMethod())),
country);
return ((IEnumerable<Customer>)(result));
}
and I don't have to call DataContext.Attach with the "Customers" that come back from executing this stored procedure, they're already known about by the DataContext.
The other thing I'd say is that I searched quite a bit to find the UpdateMethodAttribute, InsertMethodAttribute, DeleteMethodAttribute that I'd used in the previous CTP but they're gone and I had to use Reflector in the end to determine that the way to do it now is just to have;
public partial class NorthwindDataContext : DataContext
{
public void UpdateCustomer(Customer c1, Customer c2)
{
...
}
and, from what I can see the calling code just looks for methods called UpdateENTITYNAME, InsertENTITYNAME, DeleteENTITYNAME with the right type and number of parameters on your derived DataContext and uses those (framework method is SimpleChangeDirector.DiscoverChangeMethods if you want to have a look).
Posted
Sat, Mar 3 2007 5:05 AM
by
mtaulty