我有一個類LINQ到填充類
public class Row : IExtensible
{
public Row();
[ProtoMember(1, IsRequired = true, Name = "key", DataFormat = DataFormat.Default)]
public byte[] key { get; set; }
[ProtoMember(2, Name = "values", DataFormat = DataFormat.Default)]
public List<Cell> values { get; }
}
我可以使用以下的方法手動填充的值:
編輯: //列和數據是樣品字節[]值
CellSet.Row row = new CellSet.Row { key = sampleKey };
Cell value = new Cell { column = column1, data = data1 };
row.values.Add(value);
我需要填充的LINQ這些值,這是我一直在努力:
var result =
(
from a in firstrow
let valuesset = a.Split(',')
from l in valuesset
select new CellSet.Row
{
key = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()),
//values = new List<Cell>() //Not possible since only get is there
}
).ToList();
如何將值添加到對象CellSet.Row?
我還試圖此
//Edit:
//Read the xml file row by row and process it
var result =
(
from a in firstrow
let valuesset = a.Split(',')
from l in valuesset
select new CellSet.Row
{
key = Encoding.UTF8.GetBytes(Guid.NewGuid().ToString()),
//values = new List<Cell>() //Not possible since only get is there
}.values.Add(value12)
).ToList();
在值獲得一個錯誤,如:
類型的表達式「字符串[]」沒有在隨後允許從子句的IEnumerable <>
你從哪裏得到column1和data1?我們如何從'valuesset'中提取它們? –