tags:

views:

42

answers:

0

Hi!

I'm new to C# and SubSonic (coming from the comfortable C++ world), and I'm trying to understand what I'm doing wrong here:

public class TestCycleElement {
  public int ID {set; get;}
  public int SessionID {set; get;}

  public TestCycleElement() {
  }
}

public class BloodPressure : TestCycleElement {
  public BloodPressure() : base () {
  }
}

public class DataModel<Model> where Model : TestCycleElement, new() {
  public Model m;
  public DataModel(int SessionID) {
    m = ORM.repo.Single<Model>(x=>x.SessionID==SessionID);
  }
}

public class BloodPressureModel : DataModel<BloodPressure> {
  public BloodPressureModel(int SessionID) : base (SessionID) {
  }
}

I'm getting the following backtrace from the constructor of BloodPressureModel:

System.ArgumentException: The field handle and the type handle are incompatible.
at System.Reflection.FieldInfo.GetFieldFromHandle (System.RuntimeFieldHandle,System.RuntimeTypeHandle) <0x0008b>
at Models.DataModel`1..ctor (int) <0x0014f>
at Models.BloodPressureModel..ctor (int) <0x00017>
at Controllers.BloodPressureController.Submit () <0x0009b>
....

Any suggestions? I'm trying to get a genericly templated system for handling DataModels containing common SessionID columns.