Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

complex type in entity framework

When I need to use the complex type in entity framework?? or in other words what is the complex type used for ?

Thanks

like image 526
kathy Avatar asked Apr 21 '10 16:04

kathy


People also ask

What is a complex type?

A complex type describes the structure of one or more complex elements. Complex types are an essential part of every message model, because they define the logical structure of the messages and elements in the model.

What is use of complex type in OData?

Context. Use complex types to define structured properties for entity types or other complex types without exposing complex types themselves as an independent OData entity.

What is complex type web technology?

Complex types are nested data structures composed of primitive data types. These data structures can also be composed of other complex types. Some examples of complex types include struct(row), array/list, map and union. Complex types are supported by most programming languages including Python, C++ and Java.


1 Answers

In EF4, it's used mostly for returned values from stored procedures that don't match exactly onto an existing entity in your model. See Julie Lerman's blog post A big step for Stored Procedures in EF4 on this topic.

If you have a stored proc that returns e.g. a CustomerID, CustomerName and the total sales for that customer for last year, and you don't have any entity that matches these three fields, you can easily create a new complex type in the entity model "on the fly" to capture those value sets returned from your stored proc.

That's probably the most useful and most common usage of complex types, as far as I can tell.

For more on EF4 complex types, see Julie Lerman's blog post: Complex Types in the EDM Designer in EF4 and a look at updating complex types in code

UPDATE: there's a new interesting blog post by the EF4 team on how to "sniff stored procedure return types" and how to use automatic complex types for those return types.

like image 190
marc_s Avatar answered Sep 20 '22 18:09

marc_s