I have the following entities
Item
virtual public int serialNumber { get; set; }
virtual public Project idProject { get; set; }
virtual public string type{ get; set; }
Project
virtual public int idProject { get; set; }
virtual public string projectName { get; set; }
virtual public int numDovelas { get; set; }
virtual public IList<Item> lItems{ get; set; }
Both classes are mapped and they work just fine, but my question is about how can I get with one query a Project element with the lItems already filled with the items that are of that project
UPDATE (after Niyaz answer)
I have added a third entity to the model which represents the type of Analysis for an Item, and an item can have several Analysis performed on different dates and save on different files. So the mapping of that third entity is as follows
Table("Analysis");
CompositeId()
.KeyReference(x => x.SerialNumber, "serialNumber") // Reference to the Item entity
.KeyProperty(x => x.MeasureDate, "measureDate")
.KeyProperty(x => x.FileName, "fileName");
Map(x => x.Measure1).Column("measure1").Not.Nullable().Default("0");
Map(x => x.Measure2).Column("measure2").Not.Nullable().Default("0");
And I've added to the Item mapping the following
HasMany(x=>x.LAnalysis).KeyColumn("serialNumber")
To add the type of the relationship and the column that is the FK
But now I have the following error
Foreign key (FK9CF1483E7BAABE07:Analysis [SerialNumber])) must have same number of columns as the referenced primary key (Item [SerialNumber, ProjectID])
So it appears that the Analysis table must have as well the ProjectID, there is no way to avoid that? Or something that can be done to avoid this error