Distinct objects & distinct based on a specific propertie (in this case Mobile and Fax) by LINQ

//distinct objects
List<objects> listObjects = (from obj in db.Objects                             
                             select obj).Distinct().ToList();
//distinct based on a specific propertie (in this case Mobile and Fax)
List<Objects> listObjects = (from obj in db.Objects                             
                                select obj).GroupBy(n => new {n.Mobile, n.Fax})
                                           .Select(g => g.FirstOrDefault())
                                           .ToList();

Comments

Popular posts from this blog

Easy Ui Jquery easyui-textbox change onChange event

Provision AWS EC2 Instance and RDS with Terraform, and Deploy Spring Boot App to EC2 Instance via GitHub Action Pipeline

npm install gets stuck at fetchMetadata