I have a list of users returned in a class
My Class: List
public class EmployeeList
{
public int Emp_No { get; set; }
public string Sys_Prefix { get; set; }
public short Company_No { get; set; }
public string Surname { get; set; }
public string First_Name { get; set; }
public string Known_As { get; set; }
public string Initials { get; set; }
public string Title { get; set; }
}
without looping through the results of this class i want to add the results to a new list var newsFeedEmps = new List<NewsFeedEmployees>();
public partial class NewsFeedEmployees
{
public long Company_No { get; set; }
public long Emp_No { get; set; }
public long SourceId { get; set; }
public string Sys_Prefix { get; set; }
public long NewsFeedID { get; set; }
public bool isActive { get; set; }
}
I cant use newsFeedEmps.AddRange(EmployeeList) because not all the parameters match and i will be assigning a separate value to NewsFeedID and isActive for the full list
I don't want to use a foreach loop to loop through the first list and do a newsFeedEmps.Add(new .... ) I found a separate post mentioning
Queue<NewsFeedEmployees> myQueue = new Queue<NewsFeedEmployees>();
myQueue.EnqueueRange(emps.Select(emp => new NewsFeedEmployees()
{
Company_No = emp.Company_No,
Emp_No = emp.Emp_No,
}));
But i get an error that Queue does not contain a definition for EnqueueRange
O(n)
operation.var newList = oldList.Select(...).ToList();
, but internally that's using loops anyway.