O'Reilly logo

Programming Entity Framework, 2nd Edition by Julia Lerman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix B. Data-Binding with Complex Types

In Chapter 14, you learned how to create complex types and use them to encapsulate properties in an entity. As an example, you temporarily encapsulated a number of properties (Street1, Street2, City, and StateProvince) of the Address entity into a complex type called Mail, as shown in Figure B-1.

The Address entity with its Mail complex property

Figure B-1. The Address entity with its Mail complex property

The chapter looked briefly at data binding when an entity contains a complex type. Complex types may not behave the way you would expect them to in data binding. Therefore, this appendix will take a look at a number of specific data-binding scenarios that you may encounter in your applications.

Using Complex Types with ASP.NET EntityDataSource

When you use complex types with the EntityDataSource, the EntityDataSource “flattens” the properties within the complex type to make them easily accessible. When configuring the EntityDataSource, you will see the type, but not the properties. However, when binding controls to the data source, the properties of the complex type appear as though they were simply properties of the parent type. You can see this in the screenshot in Figure B-2.

The complex type properties automatically flattened

Figure B-2. The complex type properties automatically flattened

This flattening of the properties is a feature of the ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required