sql server - Linq query with non-nullable navigation property translated to left join -


i have following linq-query (false , true because of dynamically creating query):

(from x in ((objectquery<personview>)personview).mergeas(0) x.info && (((false || (true && (x.person.firstname == comparevalue))) || (true && (x.person.firstname == comparevalue))) || (true &&     ((x.person.firstname == "") || (x.person.firstname == null)))) (x.datetime >= startdate.date) && (x.datetime <= enddate.date) select x.personid).distinct() 

and translates sql query:

select  [distinct1].[personid] [personid] ( select distinct      [extent1].[personid] [personid]      (select             [personview].[personid] [personid],             [personview].[datetime] [datetime],             [personview].[info]         [info]            [core].[personview]     [personview]) [extent1]            left outer join [core].[persons] [extent2] on [extent1].[personid] = [extent2].[personid]            ([extent1].[info] = 1) , ([extent2].[firstname] in (@p__linq__0,@p__linq__1,n'') or [extent2].[firstname] null) , ([extent1].[datetime] >= @p__linq__2) , ([extent1].[datetime] <= @p__linq__3) )  [distinct1] 

my goal replace left join inner join because of performance. have been searching , have read if property not nullable (person in case not nullable) should translated inner join. not case here. how can make entity framework generate inner join?

edit: here explained required assocation should translate inner join. makes required association? in case foreign key not nullable.

i work database first. generated:

public partial class personview: dbentity {         private int _personid;     private system.datetime _datetime;     private bool _info;     public int personid { get{ return _personid;} set{ _personid = value; onpropertychanged("personid");} }     public system.datetime datetime { get{ return _datetime;} set{ _datetime = value; onpropertychanged("datetime");} }     public bool info{ get{ return _info;} set{ _info = value; onpropertychanged("info");} }      public virtual person person { get; set; } }  

i tried adding metadata makes no difference.

[metadatatype(typeof(personviewmetadata))] public partial class personview {    } public sealed class personviewmetadata {   [required]   public person person { get; set; } } 


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -