views:

55

answers:

0

Hi guys,

My code below showing 444 Identical records when it runs. but when you run the produce hql statement below on SQL server its 444 unique records which is the what I am expecting.

Did I miss any thing?

Mapping:

    public class AccessibleDocumentsDtoMap :
ClassMap<AccessibleDocumentsDto>
    {
        public AccessibleDocumentsDtoMap()
        {
            WithTable("dbo.RoleDocument");
            Id(x => x.RoleId)
                .TheColumnNameIs("RoleID");
            Map(x => x.DocId)
                .ColumnName("DocID")
                .Not.Nullable();
            Map(x => x.WithAccess)
                .FormulaIs("case when AllowFullAccess = 1 or AllowEdit
= 1 or AllowRead = 1 or AllowView = 1 then 1 else 0 end");
                //.FormulaIs("case when 1 = 1 then 1 else 0 end");
            References(x => x.DocumentReference)
                .LazyLoad()
                .WithForeignKey("DocID")
                .TheColumnNameIs("DocId");

        }
    }

public class ProficiencyReferenceDtoMap :
ClassMap<ProficiencyReferenceDto>
    {
        public ProficiencyReferenceDtoMap()
        {
            WithTable("dbo.DocCodes");
            Id(x => x.DocId)
                .TheColumnNameIs("DocId");
            Map(x => x.Description)
                .ColumnName("DocName")
                .WithLengthOf(250)
                .Nullable();
            Map(x => x.EnableOnEditCv)
                .ColumnName("EditCV")
                .Nullable();
            Map(x => x.EnableOnIntCv)
                .ColumnName("IntCV")
                .Nullable();
            Map(x => x.EnableOnPrintCv)
                .ColumnName("PrintCV")
                .Nullable();
            Map(x => x.HideMode)
                .ColumnName("HideMode")
                .Nullable();
            Map(x => x.TypeId)
                .ColumnName("TypeId")
                .Not.Nullable();
          }
    }

My code:

    IList<AccessibleDocumentsDto> documents = session
                .CreateQuery("select distinct ad.* from
AccessibleDocumentsDto ad " +
                             "where " +
                "ad.RoleId =:roleid and ad.DocumentReference.TypeId
=:typeid and  ad.DocumentReference." + cvFilterCondition)
                .SetInt32("roleid", roleId)
                .SetInt32("typeid", typeId)

Statement got from NUnit:

select accessible0_.RoleID as RoleID48_, accessible0_.DocID as
DocID48_, accessible0_.DocId as DocId48_, case when
accessible0_.AllowFullAccess = 1 or accessible0_.AllowEdit = 1 or
accessible0_.AllowRead = 1 or accessible0_.AllowView = 1 then 1 else 0
end as formula29_ from dbo.RoleDocument accessible0_, dbo.DocCodes
proficienc1_ where (accessible0_.RoleID=@p0 )and
(proficienc1_.TypeId=@p1  and accessible0_.DocId=proficienc1_.DocId)and
(proficienc1_.EditCV=1  and accessible0_.DocId=proficienc1_.DocId); --
@p0 = '57', @p1 = '8'

br,

No Body