How to make LINQ execute a (SQL) LIKE range search

后端 未结 3 1118
北恋
北恋 2020-12-06 23:29

I am in big need of help, i have been trying to do this for some time now.

So I have this Query:

Select name from BlaBlaBla

order by 

case when nam         


        
3条回答
  •  鱼传尺愫
    2020-12-06 23:48

    Below you see a sample for this kind of way to handle cases for your orderings.

        static void Main(string[] args)
        {
            List list = new List();
            for (int i = 0; i < 100; i++)
            {
                list.Add(new Obvious(i.ToString(), i));
            }
    
            string name = list[30].name;
            switch (name)
            {
                case "9":
                    list.OrderBy(o => o.perc)
                        .ThenByDescending(o => o.name);
                    break;
                default:
                    list.OrderByDescending(o => o.name)
                        .ThenBy(o => o.perc);
                    break;
            }
        }
    
        public class Obvious
        {
            public string name { get; set; }
            public int perc { get; set; }
            public Obvious(string _name, int _perc)
            {
                this.name = _name;
                this.perc = _perc;
            }
    
        }
    

提交回复
热议问题