Skip to main content
added 281 characters in body
Source Link
Andrey Bobrov
  • 2.7k
  • 11
  • 27

Languages

You can modify your query adding a language parameter:

// This can be also defined somewhere in config, etc.
var defaultLang = "en"

var contextLang = Sitecore.Context.Language != null ? 
        Sitecore.Context.Language.Name : DefaultLanguageName;

query.Where(item => item.Title.Equals("keywordinput") 
        && (item.Language == contextLang || item.Language == defaultLang));
...

You can also use the predicate builder to make sure the queries are more readable.

 

Versions

In order to achieve that you can use the inbound/outbound filter.

Please, refer to the doc

If that doesn't help, you can define a new field on the indexable:

[IndexField(“_latestversion”)]
public bool IsLatestVersion { get; set; }

And then use the following condition in your query:

.Where(item => item.IsLatestVersion)

Languages

You can modify your query adding a language parameter:

// This can be also defined somewhere in config, etc.
var defaultLang = "en"

var contextLang = Sitecore.Context.Language != null ? 
        Sitecore.Context.Language.Name : DefaultLanguageName;

query.Where(item => item.Title.Equals("keywordinput") 
        && (item.Language == contextLang || item.Language == defaultLang));
...

You can also use the predicate builder to make sure the queries are more readable.

Versions

In order to achieve that you can use the inbound/outbound filter.

Please, refer to the doc

Languages

You can modify your query adding a language parameter:

// This can be also defined somewhere in config, etc.
var defaultLang = "en"

var contextLang = Sitecore.Context.Language != null ? 
        Sitecore.Context.Language.Name : DefaultLanguageName;

query.Where(item => item.Title.Equals("keywordinput") 
        && (item.Language == contextLang || item.Language == defaultLang));
...

You can also use the predicate builder to make sure the queries are more readable.

 

Versions

In order to achieve that you can use the inbound/outbound filter.

Please, refer to the doc

If that doesn't help, you can define a new field on the indexable:

[IndexField(“_latestversion”)]
public bool IsLatestVersion { get; set; }

And then use the following condition in your query:

.Where(item => item.IsLatestVersion)
Source Link
Andrey Bobrov
  • 2.7k
  • 11
  • 27

Languages

You can modify your query adding a language parameter:

// This can be also defined somewhere in config, etc.
var defaultLang = "en"

var contextLang = Sitecore.Context.Language != null ? 
        Sitecore.Context.Language.Name : DefaultLanguageName;

query.Where(item => item.Title.Equals("keywordinput") 
        && (item.Language == contextLang || item.Language == defaultLang));
...

You can also use the predicate builder to make sure the queries are more readable.

Versions

In order to achieve that you can use the inbound/outbound filter.

Please, refer to the doc