I have 2D matrix in C# which is built a little complicated. This is the code of matrix generation:
string[][] learningInputNotCodified = learningDataRaw.Select(ldr => new string[] {
ldr.ChangeType.ToString(),
ldr.MutationOperator.Name??"null",
ldr.MutationOperator.Before??"null",
ldr.MutationOperator.After??"null",
ldr.SLOC.ToString(),
dBContext.TestCases
.Count(tc => tc.UserMutantPlay.MutantId == ldr.Id).ToString(),
dBContext.TestCases
.Where(tc => tc.UserMutantPlay.MutantId == ldr.Id)
.Select(rtc => new {
killCount = dBContext.TestCases
.Where(tc => tc.IsMutantKilled
&& tc.UserMutantPlay.MutantId == ldr.Id
&& !tc.InputValues.Any(iv =>
rtc.InputValues.FirstOrDefault(iv1 => iv1.InputParameterId == iv.InputParameterId).ValueAsString != iv.ValueAsString))
.Count()
}).Sum(tc => tc.killCount).ToString(),
ldr.OriginalCode.Mutants.Count().ToString(),
ldr.ASTDiff??"null"
}.Concat(
ldr.ParseSubTrees.OrderBy(pst => pst.Height).Select(pst => pst.SerializedTree).ToArray()
).ToArray()).ToArray();
Don't worry about the above code. The problem is that I want the matrix to be square. the columns which are hard coded are OK, but those that come from DB ldr.ParseSubTrees.OrderBy(pst => pst.Height).Select(pst => pst.SerializedTree).ToArray() make problem. Before reaching this statement (big statement) I have queried the DB for the max size. So I know the size and just want something like this:
ldr.ParseSubTrees.OrderBy(pst => pst.Height).Select(pst => pst.SerializedTree).ToArray(maxParseTreeDepth)
Although this is example of the thing I need and not the solution but I need to define the array size in a form like this.
And before you suggest solutions, I have to note that Array.Resize won't help. Because it needs a saved object as ref and in a select expression I can't do that.