开发者

How to populate IList<t> from DataTable or from a table in database?

开发者 https://www.devze.com 2023-01-11 11:25 出处:网络
I have a table say, Student. I have a class \'Student\'. I want to populate IList<Student> with objects 开发者_开发知识库of Student class from Student table in database.

I have a table say, Student. I have a class 'Student'. I want to populate IList<Student> with objects 开发者_开发知识库of Student class from Student table in database.

Is it possible to implement this?

If yes then how to implement this.

Please help.


Have a read of this:

Beginners guide to accessing SQL Server through C#


You could use a strongly typed Dataset for this. So you dont need to implement classes for your data access layer, because they will be generated automatically.

When you need a generic List of its type, you could extend the partial auto-generated Dataadapter-Class(not in the designer.cs from the Dataset but in its codebehind) with such a function.

0

精彩评论

暂无评论...
验证码 换一张
取 消