下面是我的 ActionMethod 的一部分。我正在努力的部分是使用 db.IntegerBuffers 中的所有 IntegerBufferValues 铸造一个新的变量整数,然后将它们添加到db.IntegerList。
var integers = new ICollection<Integers>();
const int COUNT = 1000000;
Stopwatch watch = Stopwatch.StartNew();
for (int c = 0; c < COUNT; c++)
{
integers = db.IntegerBuffers.OrderBy(i => i.IntegerBufferValue);
};
watch.Stop();
var integerList = new IntegerList
{
Direction = direction,
Performance = watch.ElapsedMilliseconds,
Integers = integers
};
db.IntegerLists.Add(integerList);
整数列表
namespace Project.Models
{
public class IntegerList
{
public int IntegerListID { get; set; }
public string Direction { get; set; }
public long Performance { get; set; }
public virtual ICollection<Integer> Integers { get; set; }
}
}
整数缓冲区
namespace Project.Models
{
public class IntegerBuffer
{
public int IntegerBufferID { get; set; }
public int IntegerBufferValue { get; set; }
}
}
编辑:显示整数类。
整数
namespace IntegerSorterApp.Models
{
public class Integer
{
public int IntegerID { get; set; }
public int IntegerValue { get; set; }
public int IntegerListID { get; set; }
public virtual IntegerList IntegerList { get; set; }
}
}