Skip to main content

Posts

Showing posts from March, 2009

Entity Framework – Customising Entities

A fairly simple extension I wanted to make to one of my imported entities was to provide a read-only, concatenated property. I tend to do this on any business object that represents a person to provide a single, read-only property for their full-name.

In a simple C# class, it would look like this:

private string mstrFirstName;
private string mstrLastName;

public string FirstName
{
get { return mstrFirstName; }
set { mstrFirstName = value; }
}
public string LastName
{
get { return mstrLastName; }
set { mstrLastName = value; }
}
public string FullName
{
get { return mstrFirstName + ‘ ‘ + mstrLastName; }
}

To implement with the Entity Framework, the first thought might be to add this same property to the class produced… but of course this class is generated automatically by the framework, and hence any changes made would be overridden.

.Net’s concept of partial classes come to the rescue here. You simply make your own class with the same name as the class you wish to extend, declare it as …

Entity Framework Complex Types (IDE Issues)

Have recently been getting to grips with the Entity Framework and MVC, both of which I’m using on a relatively small project to gain an understanding of the technologies and to evaluate whether we should consider either of these technologies for more major solutions at this stage in their life-cycle.

There’s obviously a fair old learning curve involved, but armed with Julia Lerman’s book have made good progress with Entity Framework and thus far have been very impressed. Have run into a few issues of course, and the one giving me most grief is regard to complex types.

The issue arises when, having created your model from your database you want to make some customisations to it. This is an important feature, as one of the major points of this technology should be to allow you program against a model that you (the app developer) want to use and not be completely tied to the database structure.

A common requirement here would be to convert a single table (or imported entity) into two – th…

ASP.Net Ajax at Devweek 2009

Following a recommendation from a client we obtained a pass for Devweek 2009, held at the Barbican in London last week. The first session I attended was a pre-conference workshop on ASP.Net Ajax presented by Fritz Onion. I was impressed with his delivery of the subject – he had that useful but all too rare skill in presenters of being able to code and talk at the same time! We covered quite a bit of ground: reviewing the status of AJAX in the existing ASP.Net platform, the background to the technology and also getting a preview of the next release of ASP.Net Ajax 4.0.

ASP.Net Ajax Today

Server Side Controls

The latest release of the technology comes with ASP.Net 3.5 service pack 1, which builds on technologies released at various stages since November 2005. By including a script manager tag, server side DLLs download JavaScript to the client:
<asp:ScriptManager id=”ScriptManager1” runat=”server” />The key server side control is the UpdatePanel which enables partial page renderin…