views:

98

answers:

1

Hi All, Have C# question;

I've been searching for a way to lets say dynamic created objects at runtime by iterating though them and there properties/methods. so far i've played with using Reflections and foreach to illiterate the class properties. This is to display all records in various tables on a Data Grid view. However one approach I think is to use Object-rational mapping to connect, populate a dataset and then be able to display it on the Data Grid view for editing etc..

*Edit: Maybe iterating over the actually namespace of classes, all the classes inherit a class called Table so I guess there should be a method in invoking all classes at run-time to fetch the data from the database*

I've done mostly Java programming up until now so have a good idea of OO-programming just not so familiar with .NET so looking for the best approach in this.

Thanks in Advance

+1  A: 

There are object-relational libraries available in .NET. If you're targeting SQL Server, use Linq to SQL, or if you need cross-database support, try the Entity Framework.

Daniel Earwicker
Have been trying this, but the classes that define each table have no Enumerable, they are over a 1000 or so class, and it wouldn't be practical to add IEnumerable per class, so need to find an alternative approach
Darragh
If you use the pre-defined frameworks, you don't need those classes to define each table. The frameworks have the capability to automatically generate classes to provide you with a typesafe way to talk to the database.
Daniel Earwicker