Click here to Skip to main content
15,566,160 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
[HttpGet("getDeparts")]
        public async Task<ActionResult<User>> getDeparts(string DeptName)
        {

         User ues = await DBCon.department.Select(
             s => new User()
             {
                 id=s.id,
                 FirstName = s.FirstName,
                 LastName = s.LastName,
                 Gender = s.Gender,
                 DeptName = s.DeptName
             }).FirstAsync(s =>s.DeptName == DeptName.ToString());
           if(ues == null)
           {
               return NotFound();
           }
           else
           {
               return ues;
           }
        }


What I have tried:

How to shown data according to DeptName field Repeated data shown
Posted
Updated 6-Dec-22 22:11pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900