这是我遇到的一个棘手的情况。我知道这是一个简单的,但我猜我错过了。
有复杂的类型对象..
ini_set('xdebug.max_nesting_level', 200);
ListGroupMembershipUploadInput看起来像
public class GroupMembershipValidationOutput
{
public ListGroupMembershipUploadInput GroupMembershipInvalidList { get; set; }
public ListGroupMembershipUploadInput GroupMembershipValidList { get; set; }
...................... // other defs
}
现在有一个父对象列表(也是同一类型),我将分别解析有效列表和无效列表。
public class ListGroupMembershipUploadInput
{
public List<GroupMembershipUploadInput> GroupMembershipUploadInputList { get; set; }
}
我试过
GroupMembershipValidationOutput gmvo = new GroupMembershipValidationOutput();
ListGroupMembershipUploadInput lgl = new ListGroupMembershipUploadInput();
if (gmvo._invalidChapterCodes.Count != 0 || gmvo._invalidGroupCodes.Count != 0 || gmvo._invalidMasterIds.Count != 0)
{
lgl.GroupMembershipUploadInputList = new List<GroupMembershipUploadInput>();
var result = mainCollection.GroupMembershipUploadInputList
.Where(x => gmvo._invalidMasterIds.Select(y => y).Contains(x.cnst_mstr_id) ||
gmvo._invalidChapterCodes.Select(y => y).Contains(x.chpt_cd) ||
gmvo._invalidGroupCodes.Select(y => y).Contains(x.grp_cd)).ToList();
if (result.Count > 0) //Means there are some invalid items
{
lgl.GroupMembershipUploadInputList = result; //Construct the invalid listfrom result
gmvo.GroupMembershipInvalidList = lgl;
......... // How to construct the valid list
}
但它为GroupMembershipValidList指定了null ..它不会使计数为0.。
如何解决?或者它是预期的?