using System; using System.Collections.Generic; using System.Text; using System.Web.UI.WebControls; using NHibernate; using RoomsHere.DataLayer; namespace RoomsHere.JabaControls { class JabaDropDownList : DropDownList where T : class { public T SelectedEntity { get { if (this.SelectedValue == null) return null; long id = Convert.ToInt64(this.SelectedValue); ISession session = DL.SessionFactory.OpenSession(); using (session) { T entity = session.Load(typeof(T), id) as T; return entity; } } } } }