An Index query to sort LazyValue

Dec 20, 2010 at 9:41 PM
Edited Dec 21, 2010 at 7:28 PM

 

Had a problem with this linq

            //var query = from index in App.Database.Query<EventViewModel, DateTime, int>(ItemDatabase.EVENT_DATE)
            //            orderby index.Index descending
            //            select new
            //            {
            //                Id = index.Key
            //            };
            //foreach (var item in query)
            //{
            //    Items.Add(item.LazyValue.Value);
            //}

but solved it by doing this:

            var query = from index in App.Database.Query<EventViewModel, DateTime, int>(ItemDatabase.EVENT_DATE)
                        orderby index.Index descending
                        select index;
            foreach (var item in query)
            {
                Items.Add(item.LazyValue.Value);
            }



 

Coordinator
Dec 22, 2010 at 2:18 PM

In the commented linq, the query is just returning an anonymous type with an id. You're not getting the index to reference the lazy value. I'm not sure what the question is - the first shouldn't work because you're trying to reference a property that doesn't exist on the anonymous type you declared in your query.