c# - Raven db order by issue -


i have collection of documents:

{ "name": "myname", "labelkey": "mylabelkey" } 

in collection labelkey null or not in document. if try order list using linq:

session.query<mymetadata>().orderby(x => x.labelkey).tolist() 

i'm getting records have labelkey not null. if have collection of 100 documents , 2 have labelkey values, after ordering i'll 2. need order collection if have labelkey null. if try check not null exception:

could not understand how translate '(x.labelkey != null)' ravendb query. trying computation during query? ravendb doesn't allow computation during query, computation allowed during index. consider moving operation index. 

any ideas how can order collection?

approach 1

don't store nulls. on way in, check null , replace empty string.

approach 2

create static index. in map expression, use null coalescing operator, such as:

labelkey = x.labelkey ?? string.empty 

then query using index.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -