Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Stored Procedures in the March CTP
Mike Taulty's Blog

Mike's Badges

Follow on Twitter
View mike's profile on slideshare
Add to Technorati Favorites
CW Blog Awards

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
(C) Mike Taulty, 2009. All rights reserved. The information in this weblog is provided "AS IS" with no warranties, and confers no rights. This weblog does not represent the thoughts, intentions, plans or strategies of my employer. It is solely my opinion. Inappropriate comments will be deleted at the authors discretion. All code samples are provided "AS IS" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems