Using Projections with mappings that have component/references

12 views
Skip to first unread message

Scott

unread,
Aug 23, 2012, 6:41:15 AM8/23/12
to nhu...@googlegroups.com
I noticed when using any kind of a projection on a mapping that contains either a component or a reference the component/reference gets cut off in the query.

If there's any restrictions on the component/reference then the query fails.

Example:
        public ItemMap()
        {
            Table("Item");
            Id(x => x.KeyColumn);

            Map(x => x.SomeData1);
            Map(x => x.SomeData2);

            References(x => x.SomeReference, " KeyColumn ")
                .Fetch.Join();
        }

session.CreateCriteria<Item>()
    .Add(Restrictions.Eq("SomeReference.Column2", "value"))
    .SetProjection(Projections.Constant("1"))
    .List();

Obviously this isn't something real, but it doesn't matter which projection is used, Projections.RowCount() or anything. This will fail because the join gets removed. Is there anything I can do to get around this?
Reply all
Reply to author
Forward
0 new messages