where - EntityFrameworkCore Linq error: variable 'country.Country' of type 'Country' referenced from scope '', but it is not defined -


entityframeworkcore: 1.1.0

i invalidoperationexception "simple" linq query , cannot figure out why. works tags, not countries.

i try execute following query:

var tags = new string[]{"guid1", "guid2"}; var countries = new int[]{1, 2}; var test = _dbcontext.articles             .include(a => a.countries).theninclude(c => c.country)             .include(a => a.tags)             .where(article => article.tags.any(t => tags.contains(t.tag.id)) &&                               article.countries.any(c2 => countries.contains(c2.country.id)))            .tolist(); 

and following exception:

variable 'c2.country' of type 'country' referenced scope '', not defined

with following entities:

public class article {     /// <summary>     /// unique id of article     /// </summary>     [required]     public guid id { get; set; }      /// <summary>     /// article type     /// </summary>     [required]     public articletypes type { get; set; }      /// <summary>     /// gets or sets article tags.     /// </summary>     /// <value>     /// article tags.     /// </value>     public icollection<articletag> tags { get; set; }      /// <summary>     /// gets or sets countries.     /// </summary>     /// <value>     /// countries.     /// </value>     public icollection<articlecountry> countries { get; set; } }  public class articlecountry {     /// <summary>     /// gets or sets identifier.     /// </summary>     /// <value>     /// identifier.     /// </value>     public guid id { get; set; }      /// <summary>     /// gets or sets country.     /// </summary>     /// <value>     /// country.     /// </value>     public country country { get; set; }      /// <summary>     ///      /// </summary>     public int position { get; set; } }  public class country {     /// <summary>     /// gets or sets identifier.     /// </summary>     /// <value>     /// identifier.     /// </value>     [jsonignore]     public int id { get; set; }      /// <summary>     /// unique country code     /// </summary>     [jsonproperty("key")]     [required]     [stringlength(2)]     public string code { get; set; }      /// <summary>     /// country name     /// </summary>     [jsonproperty("name")]     [required]     public string name { get; set; } }  public class tag {     /// <summary>     /// tag unique key     /// </summary>     [jsonproperty("key")]     [required]     public guid id { get; set; }      /// <summary>     /// tag name     /// </summary>     [jsonproperty("name")]     [required]     public string name { get; set; } }  public class articletag {     /// <summary>     /// gets or sets identifier.     /// </summary>     /// <value>     /// identifier.     /// </value>     [required]     public guid id { get; set; }      /// <summary>     /// gets or sets order.     /// </summary>     /// <value>     /// order.     /// </value>     [required]     public int position { get; set; }      /// <summary>     /// gets or sets tag.     /// </summary>     /// <value>     /// tag.     /// </value>     [required]     public tag tag { get; set; } } 

i can see following warning in console:

warn: microsoft.entityframeworkcore.query.internal.sqlserverquerycompilationcontextfactory[8] linq expression '{__countries_1 => contains(convert((?[c2.country].id?)))}' not translated , evaluated locally. configure warning use dbcontextoptionsbuilder.configurewarnings api (event id 'relationaleventid.queryclientevaluationwarning'). configurewarnings can used when overriding dbcontext.onconfiguring method or using adddbcontext on application service provider.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -