public Associate.Associate LoginUser(string userid, string pwd) { try { using (AssociateConnDataContext asscon = new AssociateConnDataContext()) { var Associate = (from a in asscon.getAthenticateUser(userid, pwd) select new Associate.Associate() { AssociateID=a.AssociateID, //Designation = a.Designation, //DesignationID = a.DesignationID , //DirectReportID = a.DirectReportID, //DirectReporter = a.DirectReporter, //DOB = a.DOB, //DOJ = a.DOJ, email=a.email, Gender=a.Gender, //Location = a.Location, //LocationID = a.LocationID, Mobile = a.Mobile, Name=a.Name, //ProjectID=a.ProjectID.Value, //ProjectName=a.ProjectName, IsApproved=a.IsApproved }).SingleOrDefault(); Associate.groupList = (from b in asscon.getAssociateRoleGroup(userid) select new Associate.Group() { GroupDesc = b.GroupDesc, GroupName=b.GroupName, GroupID = b.GroupID.Value }).ToList<Associate.Group>(); Associate.Role = (from b in asscon.getAssociateRoleGroup(userid) select new Associate.Role() { RoleDesc = b.RoleDesc, RoleID = b.RoleID.Value }).FirstOrDefault(); if (Associate.groupList.Count > 0) { return Associate; } else { throw new Exception("No group available for the user"); //return null; } } } catch (Exception e) { throw e; } }