user110542
user110542

Reputation:

NHibernate Joins Returns array of objects. Why?

I dont understand why NHibernate returns an object[] when a join is performed but Hibernate does not. For example.

The mapping

The query session.CreateQuery("From CameraMount m left join m.Presets").List();

This will return an object[] where I would expect it to return a CameraMount that has its set of Presets initialized.

Why?

Upvotes: 2

Views: 811

Answers (2)

Sree
Sree

Reputation: 11

Also, you can try Select m from CameraMount m left join m.Presets This should give you the CameraMount Objects back.

Upvotes: 1

martijn_himself
martijn_himself

Reputation: 1570

I guess this is just the implementation that is slightly different due to support for generic and non-generic collections in .NET. If you want strongly typed CameraMount objects you could request:

List<CameraMount> cameramounts = 
session.CreateQuery("From CameraMount m left join m.Presets")
.List<CameraMount>();

instead. Hope that helps.

Upvotes: 1

Related Questions