March 2009 Entries
I few months ago I took a pledge to: "I will publish a blog post on Tuesday 24th March about a woman in technology whom I admire but only if 1,000 other people will do the same." to celebrate Ada Lovelace day. That time has come! Michele Leroux Bustamante – author of a book I deem as one of the best books I’ve bought to get me into SOA and learning WCF… Without it I wouldn’t have got half as far as I have! Now – aside from the selfish reason of the fact that she has helped me with the book – I admire ......
Right, in my last post I wrote about creating a DBML file and hooking it all up through WCF, however, we only got to ‘retrieving’ from the database via the service. So, let’s presume you want to upload… We already had our contract: [ServiceContract] public interface ICarsService { [OperationContract] Car GetCar(int id); [OperationContract] void SubmitCar(Car car); } Of which we’ve tested the ‘GetCar’ method, let’s get to implementing the ‘SubmitCar’ method. We actually did implement some code in ......
I realised whilst reviewing some code that you can also implement the IEquatable<T> interface as well just overriding the Equals (or indeed, in place of doing that). So, back to our Simple class, we could actually write it as such: internal class Simple : IEquatable<Simple> { public int TheInt { get; set; } public string TheString { get; set; } public Simple(int theInt, string theString) { TheInt = theInt; TheString = theString; } public bool Equals(Simple other) { if(other == null) return ......
A gotcha that got me :) If you’re used to using List<T> collections, and in particular the way they compare, then you need to know that an EntitySet (from LINQ to SQL) does the comparison differently… In my experience, if I’ve created a class, for example: internal class Simple { public int TheInt { get; set; } public string TheString { get; set; } public Simple(int theInt, string theString) { TheInt = theInt; TheString = theString; } } And I then add some instances of this class to a List<Simple>, ......
Now, I may be doing this wrong, but at the moment, it works :) I’m writing a service to communicate with a database, and provide a consistent front end for the applications that will be using it. In the past that has meant writing tonnes of CRUD (Create Read Update Delete) code, usually via Stored Procs, which are then accessed by a ‘DbAccess’ helper class of some variety. Not to mention the added bonus of writing the classes to store the data as it comes out. Fortunately the database I’m accessing ......