Question

I have a Guid List type of varchar(Max). This list has lots of Guid's which cross the sql limit.SO i have break this list in to small list as shown below.

 var sublists = customerList
               .Select((x, i) => new { Index = i, Value = x })
               .GroupBy(x => x.Index / 2000)
               .Select(x => x.Select(v => v.Value.ToString()).ToList())
               .ToArray();

But this list is coming in char format as shown below.

enter image description here

I am not getting why this is coming in char format. Am I making any mistakes?

Was it helpful?

Solution

If customerList is a big string:

var sublists = customerList
    .Split(",")
    .Select((x, i) => new { Index = i, Value = x })
    .GroupBy(x => x.Index / 2000)
    .Select(x => x.Select(v => v.Value).ToList())
    .ToList();

Is the same solution as here but you must add Split Method first.

OTHER TIPS

Try this:

string[] sublists = customerList.Substring(0,2000).Split(',');
sublists = sublists.Take(sublists.Length - 1).ToArray();

That should give you the results you are looking for.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top