Im running through a list and extracting the position value from each record
string allPositionsListed = "";
int lastRecord = volunteerAssignmentList.Count;
int currentRecord = 0;
foreach (Volunteer va in volunteerList)
{
currentRecord++;
if (currentRecord == lastRecord)
{
allPositionsListed += va.Position;
}
else
{
allPositionsListed += va.Position + ",";
}
}
//allPositionsListed returns: "51000785,52012986"
I have written a query extracting all the records from the positionTable where position is found.. if I use
var allPositions = new string[] { "51000785", "52012986" };
List<PositionTable> positionList = (from p in DbContext.PositionList
where allPositions.Contains(p.Position)
select p).ToList();
this returns the correct results...but as the allPositions values may be different how do I convert it to the necessary string array. ive tried
var allPositions2 = allPositionsListed.ToArray();
but this returns
[0]5
[1]1
[2]0
[3]0
[4]7
etc...
when I need
[0]51000785
[1]52012986