views:

113

answers:

0

As part of a system which I am developing I need a method of taking a set of class definitions which define an object model and constructing a dataset from them which can then be populated by instantiating instances of the classes (either singletons or through collections for multiple table rows).

The kind of approach I had in mind would use attributes to decorate the class definition.

e.g.

[Table("MyData")]
class MyClass
{

    [MyField]
    public int MyField() { get; set;}
}

Could generate a DataTable called MyData with a field called MyField in it. Then if there was a collection of type List<MyClass> I could populate the MyData table with the value of the MyField property.

I also need to be able to represent relationships between tables - e.g. one to many etc. so some mechanism of creating Data Relations between tables is also necessary - again possibly through attributes - e.g. [Relation(Parent="MyClass" Key="MyField")] etc.

The approach I have in mind is similar to that described here - http://www.codeproject.com/KB/cs/coreweb01.aspx but this implementation does not support relations and is geared around converting populated lists to datatables so its not quite what I'm looking for.

The data contained in these datasets will not come from any database nor do they need to go anywhere near a database so I'm not looking for anything involving SQL, DataAdapters etc.

The solution must be capable of generating an ADO.NET dataset as I am using the excellent TMS Flexcel Studio for .NET to populate an Excel spreadsheet with experimental data and this takes datasets as its main input.

I know there are numerous object relational persistence frameworks out there but it looks like most of them use don't handle datasets natively as well as being focussed on using databases. - Can anyone suggest any which are more like what I am looking for or which can output ADO.NET datasets as an option.

Many thanks for any advice.