using stored procedure in code first -


i have code first model 2 table :

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; } } 

i want select company user object stored procedure

select  a.*,u.*  [dbo].[companies]          inner join dbo.users u on u.companyid=a.companyid   companydb c = new companydb();  var cc = c.database.sqlquery<company>("dbo.company_select") 

my problem : cc.user null ???

first, have virtual in wrong place user:

public class user {     public int userid { get; set; }     public string username { get; set; }     public string password { get; set; }     public int companyid { get; set; }     public virtual company company { get; set; } } 

second, why stored procedure? when configured can do:

var companieswithusers = db.companys.include(c => c.user).tolist(); 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -