开发者

generic Data fetcher

I'd like to know a way to assign any query result to a generic List based on the mapping between column names开发者_如何学C and object's property names.

public List getData(string sql, Type object_type)

for example, I have the following sql and an object:

Select name, address, phone from ''' where ...

Class Person { string name; string address; string phone; }

public List getData(string sql, Type type) { ... }


There are packages that already do this -- it's called object-relational mapping.

http://en.wikipedia.org/wiki/Object-relational_mapping

NHibernate is a popular one.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜