Contents tagged with Generics

  • Lambda Expressions with NHibernate.Linq

    In the last two posts below I talked about creating a templated DataService class and also mused about whether UI data queries really were a cross-cutting concern. I'm agnostic about the question really; however, I do have one practical concern. I don't want to expose methods that take any old HQL query that the client sends my way. I'd like to have a controlled way of extending database queries down to the UI. Continue reading...

  • Refactor to DataService<T>

    In the post below on NHibernate 101 I said not to plumb data access code in the Operation Contract implementation. Now I'd like to refactor and get that out of there. Let's think about it a bit first. Do I really want to create a data layer class called "InstrumentService" with the CRUD in there? I could. But since this is a concert music application, I know I'm going to have several lookup tables in the system. In addition to musical instruments there will be musical genres, catalogs, recording labels, ensemble types, and so on and on. Continue reading...

  • IComparer and Sorting Widgets

    Back in the turn of the last century, the golden days of .NET 1.1, if you wanted to implement a type-safe custom collection your best bet was to derive from CollectionBase in the System.Collections namespace. CollectionBase was more than just an abstract base class. It was also a wrapper around an internal ArrayList. If you wanted to sort strongly-typed objects in the collection you would implement an IComparer class: Continue reading...

  • Generics and Nullable Types

    It is often useful in OR mapping to analyze a value type that might be null prior to setting it in a business entity. For instance, SqlDateTime type (in System.Data.SqlTypes namespace) is a value type that is nullable. You can call IsNull to check and Value to retrieve the underlying DateTime type: Continue reading...