Late binding in linq

I have a simple LINQ query that goes against a collection.

   Dim oList = From w In Os
                Order By w.ClassTitle Descending
        Select w

What I would like to do is go through it, whether it be a descent or an ascent. I do not know how to do that.

Also, if I had a where clause here .. say

where w.ClassTitle = "Test"

How can I run a "Test" to pass it to a LINQ query.

Thanks Shannon

+3
source share
2 answers

I don’t think you can pass this “in” to this request, however you can execute a normal request

var oList = from w in Os
            select w

Then, when the user takes some action, you can simply place an order after this fact.

oList.OrderBy(o => o.ClassTitle)

or

oList.OrderByDescending(o => o.ClassTitle)

UPDATE:

, , Where. , . #,

public static IEnumerable<Os> ExecuteWhere (this Table<Os> table, Expression<Func<Os, bool>> predicate)
{
    return table.AsQueryable<Os>().Where(predicate);
}

, :

oList.ExecuteWhere(a => a.ClassTitle == "Test")
+1

. :

Dim oList = Os.Where(....).OrderBy(...)...
0

Source: https://habr.com/ru/post/1761718/


All Articles