1

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?

halfer
  • 19,824
  • 17
  • 99
  • 186
Amit Kumar
  • 1,059
  • 3
  • 22
  • 43

2 Answers2

1

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.

Sergio
  • 8,125
  • 10
  • 46
  • 77
1

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.

Community
  • 1
  • 1
Najera
  • 2,869
  • 3
  • 28
  • 52
  • This is spltting smae way but sublist is not showing right output.If I have 3400 records in CustomerList then sublist should have index with (2000 and 1400 records). – Amit Kumar May 05 '14 at 17:13
  • If Customer List has 3400 list of Guid's.then It should be splits in 2 parts with index 0 and index 1.and index 0 should contain 2000 guids and index 1 should contain rest of guids. – Amit Kumar May 05 '14 at 17:28
  • Thanks. It was my mistake .Your previous solution was also right.And my problem is solved now. – Amit Kumar May 05 '14 at 18:05