0
我有2臺代碼第一種模式:使用代碼第一個存儲過程
public class Company
{
public int CompanyId { get; set; }
public string CompanyName { get; set; }
public string CompanyAddress { get; set; }
public virtual ICollection<User> User { get; set; }
}
public class User
{
public int UserId { get; set; }
public string UserName { get; set; }
public string Password { get; set; }
public virtual int CompanyId { get; set; }
public Company Company { get; set; }
}
我想選擇公司與用戶對象與存儲過程
SELECT a.*,u.* FROM [dbo].[Companies] as a
INNER JOIN dbo.Users u on u.CompanyId=a.CompanyId
CompanyDB c = new CompanyDB();
var cc = c.Database.SqlQuery<Company>("dbo.Company_Select")
我的問題:cc.User是空值 ???
因爲我需要額外的領域與一個選擇。 expamle:我需要從Comapny中選擇10行並選擇所有行數以進行分頁 –
許多用於整形和過濾的Linq to Entities選項。例如,db.Companys.Include(c => c.User).Skip((page -1)* PageSize).Take(10).ToList(); –