📜  linq select if different null - 任何代码示例

📅  最后修改于: 2022-03-11 14:57:34.710000             🧑  作者: Mango

代码示例2
using (MyTestDBEntities context = new MyTestDBEntities())
            {
                var query = context.UserTables.Where(p => p.City != null)
                    .Select(cc => new { DisplayValue = cc.UserID, DisplayText = cc.FirstName + "  " + cc.LastName + "  " + cc.City });

                DropDownList1.DataSource = query.ToList();
                DropDownList1.DataTextField = "DisplayText";
                DropDownList1.DataValueField = "DisplayValue";
                DropDownList1.DataBind();
            }