How to force outer join with .Include query Entity Framework 6

.net c# entity-framework entity-framework-6 outer-join

Question

Here is my data model.UserPhone is necessary, however the navigation characteristic is not necessary so long asUser 's table could be vacant:

public class Request
{
    [Key]
    public int Id {get;set;}
    [Required]
    public string UserPhone {get;set;}
    [ForeignKey("UserPhone")]
    public virtual User User {get;set;}
}

public class User
{
    [Key]
    public string UserPhone {get;set;}
}

The User Following the entry of a request into the system, s table is filled. I'm attempting to get all of the requests with a user, if any, between when the request is entered and when the user is not supplied (outer join).

db.Requests.Include(r=>r.User).FirstOrDefault();

I get no results as a consequence of EF's inner join (myUserPhone a foreign key that is specified and necessary for the Requests table).

How do I define the mapping correctly so that I may utilise include mapping? In order toinclude Due to the fact that my instance included other tables, I would want to utilise manual joins alone.

1
3
5/19/2017 10:33:28 AM

Accepted Answer

ZZZ_tmp
4
5/19/2017 6:54:09 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow