开发者

Using ASP.NET MVC 2 and model binding with ADO.NET EntityCollections

I found a great tutorial on how to use Model Binding and List, Editable Grid / List Bi开发者_高级运维nding in MVC2. It shows how to create objects containing lists of type List<T>. But when I use the ADO.NET entity data model I cannot make the this:

SomeEntityCollection[i]

And thereby I can not make what is done in the tutorial.

Is there a way to work around this? Maybe make the ADO.NET use lists instead, if that's possible?


The best way I have found to map from ADO.NET to models is to use AutoMapper. It's a very elegant way to formalize mapping between structures.

From their site:

AutoMapper uses a fluent configuration API to define an object-object mapping strategy. AutoMapper uses a convention-based matching algorithm to match up source to destination values. Currently, AutoMapper is geared towards model projection scenarios to flatten complex object models to DTOs and other simple objects, whose design is better suited for serialization, communication, messaging, or simply an anti-corruption layer between the domain and application layer.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜