3

I have a string of comma separated values called driverids.

  1. Should I use the comma separated list or the array that this comma separated list comes from to use this in a join.

  2. How would I use a join in linq to these driverids?


_currentDriverData.AddRange(elementsCurrent.Join(driverids)

// gets distinct driver ids from the driver duty status change logs;
string driverids = string.Join(",", _logsDutyStatusChange
                         .Select(item => item.did)
                         .Distinct()
                         .ToArray());

//gets all current driver information
//_currentDriverData.AddRange(elementsCurrent.Where(drivers)

_currentDriverData.AddRange(elementsCurrent.Join(driverids).Select.........
2
  • What are you trying to join them to? Commented Apr 18, 2011 at 15:37
  • I am trying to get only those driver id's in my select Commented Apr 18, 2011 at 15:39

1 Answer 1

2

You would do something like this (assuming _currentDriverData us a list of ids):

_currentDriverData.AddRange(commaSeparatedString.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyElements).ToList());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.