我試圖檢索公司的交易。我已經包含了entites和檢索方法。如圖所示,這些公司已經在內部交易。asp.net實體框架代碼第一個外鍵不能檢索
//company entity
public class Companies
{
public int id { get; set; }
public string companyID { get; set; }
public string companyName { get; set; }
public bool companyMointor { get; set; }
}
//trade entity
public class Trade
{
public int id { get; set; }
public DateTime tradeDate { get; set; }
public double tradePrice { get; set; }
public int tradeQuantity { get; set; }
public Companies tradeCompany { get; set; }
public int type { get; set; }
public types tradeType
{
get { return (Entities.types)type; }
set { type = (int) value; }
}
}
//methods to retrieve
public List<Trade> getTrade()
{
List<Trade> trades = (from t in dbContext.trades
orderby t.tradeDate descending
select t).ToList();
return trades;
}
什麼是你的問題,是公司變空?在交易清單中? –
yes,is empty ... – user2514963