Hello
Please Help me
System.InvalidOperationException Collection was modified; enumeration operation may not execute.
at System.Collctions.Generic.List'1.Enumeraor.MoveNextRare()
at System.Linq.Enumerable.WhereListIterator'1.MoveNext()
at System.Linq.Butter'1.ctor(IEnumerable'1 source)
Please Help me
System.InvalidOperationException Collection was modified; enumeration operation may not execute.
at System.Collctions.Generic.List'1.Enumeraor.MoveNextRare()
at System.Linq.Enumerable.WhereListIterator'1.MoveNext()
at System.Linq.Butter'1.ctor(IEnumerable'1 source)
C#:
public string GetMList(ref MDataFormat mts, bool setItem = false)
{
string ret = null;
Dictionary<string, string> delList;
delList = mts.DeleteOverLayer();
bool isTail = false;
Dictionary<string, int> addID = AddSetValueIDsAtMTS(ref mts, out isTail);
if (isTail) return ret;
DBAttrListDataFormat dbAttrViewList = DBAttrList.Instance(DBName).DBAttrViewList;
int viewtypeidx = dbAttrViewList.cols.FindIndex(x => x.Equals("type", StringComparison.OrdinalIgnoreCase));
IEnumerable<string[]> DBAttrListResult;
Func<string, int> customConvertToInt32 = (s) =>
{
int y = 0;
for (int i = 0; i < s.Length; i++)
y = y * 10 + (s[i] - '0');
return y;
};
if (mts.ViewLayer > 0 && viewtypeidx > -1)
DBAttrListResult = dbAttrViewList.rows.Where(x => customConvertToInt32(x[layeridx]) >= customConvertToInt32(mLayer)).Where(x => x[viewtypeidx] == viewtype.SelValue);
else
DBAttrListResult = dbAttrViewList.rows.Where(x => x[layeridx] == mLayer);
try
{
DBAttrListResult = DBAttrListResult.OrderBy(x => customConvertToInt32(x[depthidx]));
}
finally
{
}
if (mts.ViewLayer == 1)
delList.Clear();
try
{
foreach (string[] row in DBAttrListResult)
{
IEnumerable<string[]> valdt = GetAttrSetValueList(key, mts);
if (delList.ContainsKey(key))
{
bool notContains = false;
if (delList[key] != null)
{
string[] delvaluelist = delList[key].Split(',');
foreach (string delvalue in delvaluelist)
{
if (!mts.AttrList[key].ValueList.Contains(delvalue))
{
if (!setFirstItem)
{
mts.AttrList[key].ValueList.Add(delvalue);
}
else
{
notContains = true;
}
}
}
}
}
}
}
catch (Exception e)
{
return ret;
}
return ret;
}