Workaround: instead of the ResultTransformer use List<object[]> and map the
DTO using LINQ to objects
.Select(x => new HouseDto{ HouseName = (string)x[0] ... })
Diego
On Wed, Oct 20, 2010 at 01:46, Quooston <[email protected]> wrote:
> Hi,
>
> I have a DTO which I am trying to map to by means of the
> AliasToBeanResultTransformer.
>
> All works as expected until I try to utilize the second level cache
> with SetCacheable(true):
>
> houseDtos = newSession.CreateCriteria<House>()
> .SetCacheable(true)
> .SetCacheMode(CacheMode.Get | CacheMode.Put)
> .CreateAlias("Rooms", "r", JoinType.LeftOuterJoin)
> .SetProjection(Projections.ProjectionList()
> .Add(Projections.Id(), "Id")
>
> .Add(Projections.Property("HouseName"),
> "HouseName")
>
> .Add(Projections.Property("r.RoomName"),
> "FirstRoomName")
> )
>
> .SetResultTransformer(Transformers.AliasToBean(typeof(HouseDto)))
> .List<HouseDto>();
>
> which results in:
>
> NHibernate.Exceptions.GenericADOException : Unable to perform
> find[SQL: SQL not available]
> ----> System.InvalidCastException : Unable to cast object of type
> 'Leica.Bond.Server.Core.IntegrationTests.HouseDto' to type
> 'System.Object[]'.
>
> What can I do to have the second level cache play nice with the above?
>
> Thanks in advance for any input provided.
>
> Cheers
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<nhusers%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/nhusers?hl=en.
>
>
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.