I am trying to develop one single query which gives me records from both the table in one result using linq-Nhibernet query.
I have two tables first one :account (accountId , accountDescription) and second one: accountdescriptionhistory (accountId, description). AccountId is foreign-key reference to second table. Now, i am fetching all the records from first table with below query.
What i want is, If record exist in AccountDescriptionHistory for accountId reference than it should return me the description from AccountDescriptionHistory not from account table. i want to achieve this in single query.
Note : I need this in linq NHibernate query.
Adding a class details
Account class look like below :
public class Account : EntityModelHasOwner<Account>, ISupportsIdLookup
{
/// <summary>
/// The account number
/// </summary>
public virtual string AccountNumber { get; set; }
/// <summary>
/// The account's description
/// </summary>
public virtual string Description { get; set; }
}
Account description class :
public class AccountDescriptionHistory : EntityModel<AccountDescriptionHistory>
{
#region Public Properties
/// <summary>
/// The account description of an account that is valid for a specific date range
/// </summary>
public virtual string AccountDescription { get; set; }
/// <summary>
/// The account this AccountDescriptionHistory is associated with.
/// </summary>
public virtual Account Account { get; set; }
}