Conditional Multiple Fields Searching and Filtering in LINQ

后端 未结 3 1542
执笔经年
执笔经年 2021-01-03 02:05

Assuming that we have the following table:

Person:
  PersonID,
  Name,
  Age,
  Gender

And we are providing a search function that allows u

3条回答
  •  既然无缘
    2021-01-03 03:00

    why not use the null coalescing operator? eg.

    var products = from a in context.products where a.ID == (productID ?? a.ID) select a;

    This works really well on my system

提交回复
热议问题