Seb does Scotland – 23rd to 25th of September

Well, it’s been a while since I’ve been a up north, and with such a great community up there, it was only a matter of time before I got back. Frankly, I was just looking for an excuse, and the guys have given me a beautiful one!

So here’s the schedule.

Wednesday 23rd September

Dundee – http://www.eventbrite.com/event/390722662/seb

When agile goes bad, how to stay calm and move forward

With applying agile methodologies comes changes in many aspects of delivering software. And with any change will come a time when something fails. How to keep everyone calm? How to provide practical solutions to prevent people from reverting back to non-agile practices at the first roadblock? Through examples gathered from personal experience and the community, we’ll explore ways to prevent the boat from sinking at the first spilled glass of water.

Thursday 24th September

Edinburgh - http://www.eventbrite.com/event/390708620/seb

An intro to OpenRasta

Everybody seems to rediscover the MVC model, and new frameworks seem to appear all the time. Most of those hide the richness of the web. Come discover OpenRasta, a very opinionated framework that help you write MVC-style web applications and data services, using a unified API.

Friday 25th September

AltNetBeers Scotland edition

The scot alt.net guys have asked me to facilitate a session of AltNetBeers, which I’m really excited about. Will update with the details when I know where it’ll be organized.

See you there!

Ads

NHibernate repository that Oren won’t like

public interface IRepository<T> : INHibernateQueryable<T>
{
ITransaction BeginTransaction();
void Delete(T item);
T Get(object id);
void Save(T target);
void Update(T item);
}
public class NHibernateRepository<T> : IRepository<T>, IDisposable
{
readonly ISessionManager _sessionManager;

INHibernateQueryable<T> _queryable;
ISession _session;

public NHibernateRepository(ISessionManager sessionManager)
{
_sessionManager = sessionManager;
}

INHibernateQueryable<T> AsQueryable
{
get
{
if (_queryable == null)
_queryable = Session.Linq<T>();
return _queryable;
}
}

public Type ElementType
{
get { return AsQueryable.ElementType; }
}

public Expression Expression
{
get { return AsQueryable.Expression; }
}

public IQueryProvider Provider
{
get { return AsQueryable.Provider; }
}

public QueryOptions QueryOptions
{
get { return AsQueryable.QueryOptions; }
}

public ISession Session
{
get
{
if (_session == null)
_session = _sessionManager.OpenSession();
return _session;
}
}

public void Dispose()
{
if (_session != null)
_session.Dispose();
}

IEnumerator IEnumerable.GetEnumerator()
{
return GetEnumerator();
}

public IEnumerator<T> GetEnumerator()
{
return AsQueryable.GetEnumerator();
}

public IQueryable<T> Expand(string path)
{
return AsQueryable.Expand(path);
}

public ITransaction BeginTransaction()
{
return Session.BeginTransaction();
}


public void Delete(T item)
{
Session.Delete(item);
}

public T Get(object id)
{
return Session.Get<T>(id);
}

public void Save(T target)
{
Session.SaveOrUpdate(target);
}

public void Update(T item)
{
Session.Update(item);
}
}

public static class CustomerQueries
{
public static IQueryable<Customer> ByName(
this IQueryable<Customer> repo,
string name)
{
return repo.Where(x => x.Name == name);
}
public static IQueryable<Customer> ByCity(
this IQueryable<Customer> repo,
string city)
{
return repo.Where(x => x.City == city);
}

}
public class MyPage
{
IRepository<Customer> _repository;

public MyPage(IRepository<Customer> repository)
{
_repository = repository;
}

public Customer UpdateCustomer()
{
return _repository
.ByCity("Aarhus")
.ByName("Sebastien")
.FirstOrDefault();
}
}
public class when_filtering_by_city
{
public void the_wong_city_is_not_selected()
{
var myTestData = new List<Customer>
{
new Customer { City = "Aarhus" },
new Customer { City = "London" }
};
var funPlaceToBe = myTestData
.AsQueryable()
.ByCity("Aarhus")
.FirstOrDefault();

Debug.Assert(funPlaceToBe.City == "London");
}
}

public class Customer
{
public string Name { get; set; }

public string City { get; set; }
}

Ads

OpenRasta 2.0 beta 2 is out

Grab the binaries at http://www.ohloh.net/p/openrasta/download?package=OpenRasta+2.0&release=Beta+2 or the code at http://svn.caffeine-it.com/openrasta/branches/2.0.2000

Ads