The bellow given code sample is to retrieve all the active records.
session.CreateCriteria<VesselMasterData>()
.CreateAlias("BasicInfo", "bsInfo")
.CreateAlias("DimentionInfo", "diInfo")
.Add(Restrictions.Eq("IsActive", 1))
.Add(Restrictions.Eq("diInfo.IsActive", 1))
.Add(Restrictions.Eq("MasterDataID", masterDataID))
.Add(Restrictions.Eq("bsInfo.IsActive", 1))
.List<VesselMasterData>()
Parent table VesselMasterData and child tables are BasicInfo and DimentionInfo. Based on the query expected values should be all active records of the BasicInfo and DimentionInfo.
But in the out put i get all records from the BasicInfo and DimentionInfo. What could be the issue.
This is the mapping of the VesselMasterData table.
public class VesselMasterDataMap : ClassMap<VesselMasterData>
{
public VesselMasterDataMap()
{
Table("VPD_VESSEL_MASTER_DATA");
Schema("APPLN1");
Id(x => x.MasterDataID).Column("MASTER_DATA_ID").GeneratedBy.Sequence("VPD_VESSEL_MASTER_DATA_SEQ");
Map(x => x.VesselCode).Column("VESSEL_CODE");
Map(x => x.IsActive).Column("IS_ACTIVE");
HasMany<VesselBasicInfo>(prop => prop.BasicInfo)
.KeyColumns.Add("MASTER_DATA_ID").Cascade.SaveUpdate().Inverse().Not.LazyLoad();
HasMany<VesselDimension>(prop => prop.DimentionInfo)
.KeyColumns.Add("MASTER_DATA_ID").Cascade.SaveUpdate().Inverse().Not.LazyLoad();
}
}