Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an equivalent to NHibernate's <component> in Entity Framework?

We are studying which ORM technology we could use in our project, more specially NHibernate vs. Entity Framework 4.

One nice thing in NHibernate is the possibility to map several columns to a custom type, thanks to the "component" mapping option. That is, I can map a group of columns as being a property of a given specified type, like this :

    Component<MyCustomType>(e => e.CreatedBy,
        p =>
        {
            p.Map(customTypeItem => customTypeItem .prop1, "column1");
            p.Map(customTypeItem  => customTypeItem .prop2, "column2");
        });

I haven't found a similar feature in Entity Framework 4. Does it exist ? or is there a similar functionality ?

like image 243
tsimbalar Avatar asked Dec 16 '10 08:12

tsimbalar


People also ask

Is NHibernate better than Entity Framework?

Entity framework requires additional connections to handle databases other than MSSQL, which nHibernate provides. In terms of data loading, SQL generation, custom column types, custom collections, and so on, NHibernate can be modified. However, the entity framework has limited extension points.

Is NHibernate a framework?

NHibernate is a mature, open source object-relational mapper for the . NET framework. It's actively developed, fully featured and used in thousands of successful projects. Easily map regular C# or VB.NET object models designed in Visual Studio.

Why use NHibernate?

NHibernate is Designed to serve as a persistence layer exclusively for the . Net framework based on Object-Relational Mapping Technique. A tool that creates a "virtual representation" of database objects within the code. Used to solve the problem of impedance mismatch between Class and relational databases and tables.

Is hibernate similar to Entity Framework?

Hibernate is a suite of open source projects around domain models. The flagship project is Hibernate ORM, the Object Relational Mapper. On the other hand, Entity Framework is detailed as "An object-relational mapper that enables . NET developers to work with relational data".


1 Answers

Don't know much about NHibernate, but you can try EF4's Complex Type Objects.

You define them on the actual entities on your EDMX (Add -> Complex Type), as opposed to scalar properties.

Haven't tried it before - but maybe it suits your scenario.

like image 188
RPM1984 Avatar answered Sep 21 '22 12:09

RPM1984