我有这样的数据模型

我想将对帐中的所有相关实体加载到Reconciliation对象中.
目前,我可以找到将所有相关的entites加载到单个Recon的唯一方法是多个列表.但我想加载一个Reconciliation对象中的每个相关实体.如果可能的话,优雅的方式.
Reconciliation recon = db.Reconciliations
.Where(r => r.ReconNum == 382485).First();
List<ReconciliationDetail> reconDetails = recon.ReconciliationDetails.ToList();
List<JrnlEntryDetail> jrnlDetails = reconDetails.Select(r => r.JrnlEntryDetail).ToList();
List<JrnlEntry> jrnl = jrnlDetails.Select(j => j.JrnlEntry).ToList();
List<ARInvoice> invoices = jrnl.SelectMany(j => j.ARInvoices).ToList();
List<ARInvoiceDetail> invoicesDetail = invoices
.SelectMany(i => i.ARInvoiceDetails).ToList();
List<ARCredMemo> credmemos = jrnl.SelectMany(j => j.ARCredMemoes).ToList();
List<ARCredMemoDetail> credmemosDetail = credmemos
.SelectMany(c => c.ARCredMemoDetails).ToList();
List<IncomingPay> incomingPays = jrnl.SelectMany(j => j.IncomingPays).ToList();
List<IncomingPayDetail> incomingPaysDetail = incomingPays
.SelectMany(i => i.IncomingPayDetails).ToList();
// ... and so on for outgoing pays, AP …Run Code Online (Sandbox Code Playgroud) 我运行以下测试我使用此批处理创建了一个包含15,000个400字节文件的文件夹:
@ECHO off
SET times=15000
FOR /L %%i IN (1,1,%times%) DO (
fsutil file createnew filename%%i.txt 400
)
Run Code Online (Sandbox Code Playgroud)
然后我使用此命令在我的Windows计算机上复制它:
robocopy LargeNumberOfFiles\ LargeNumberOfFiles2\
Run Code Online (Sandbox Code Playgroud)
完成后我可以看到传输速率为915810字节/秒,小于1 MB/s.我花了几秒钟复制7 MBytes请注意,这是非常慢的.
我尝试使用单个文件为50 MB的文件夹,传输速率为1219512195 Bytes/sec.(是的GB/s)瞬间.
为什么复制大量文件需要花费很多时间 - 在Windows文件系统上重新编写资源?
请注意,我试图在Linux系统上执行相同的操作,该系统在具有ext3文件系统的虚拟机(vmware播放器)中的同一台计算机上运行.
我使用cp命令,副本是即时的!
另请注意以下事项:
我有一个简单的选择倍数与选项绑定如下:
<select multiple="multiple" width="50" data-bind="options: propositions, optionsText: function(item){ return item.name }, optionsValue: function(item) { return item.name }"></select>
Run Code Online (Sandbox Code Playgroud)
这可以在选项项的value属性上设置item.name,如下所示:
<option value=" item.name value here ... "> item.name also here </option>
Run Code Online (Sandbox Code Playgroud)
我想要的是设置这样的自定义属性:
<option value=" item.name " data-value = " item.name "> item.name also here </option>
Run Code Online (Sandbox Code Playgroud)
是否有可能告诉knockout 在绑定中设置属性数据值,你会怎么做?
我正在添加一个通过外部类构建的新实体,我收到此错误 A referential integrity constraint violation occurred: A primary key property that is a part of referential integrity constraint cannot be changed when the dependent object is Unchanged unless it is being set to the association's principal object. The principal object must be tracked and not marked for deletion.:
编辑:ReconFact实体未链接到任何其他实体
代码(已编辑):
// the context class
AccountingModelContext db = new AccountingModelContext();
// query some data
List<Reconciliation> recon = db.Reconciliations
.Where(r => r.ReconNum == 112293) // …Run Code Online (Sandbox Code Playgroud) 我知道这个主题已经在很多帖子中得到了处理,但我无法解决这个问题.
在一个Controller里面一个ActionResult我想在Session中存储一个对象并在另一个ActionResult中检索它.像那样 :
public ActionResult Step1()
{
return View();
}
[HttpPost]
public ActionResult Step1(Step1VM step1)
{
if (ModelState.IsValid)
{
WizardProductVM wiz = new WizardProductVM();
wiz.Step1 = step1;
//Store the wizard in session
// .....
return View("Step2");
}
return View(step1);
}
[HttpPost]
public ActionResult Step2(Step2VM step2)
{
if (ModelState.IsValid)
{
//Pull the wizard from the session
// .....
wiz.Step2 = step2;
//Store the wizard in session again
// .....
return View("Step3");
}
}
Run Code Online (Sandbox Code Playgroud) 我试图找出asp.net mvc 3中不显眼的验证是如何工作的.
我想知道当我点击提交表单时触发验证检查的是什么.如何将脚本jquery.validate.unobtrusive.js绑定到表单提交事件?
我也想知道如何手动阻止/触发此检查.
我试图从一个可以为null(数组)的对象数组中获取属性,并且我总是得到一个空引用异常.
如果它为null或返回空字符串,我怎么能告诉LINQ不处理它?
foreach (Candidate c in candidates) {
results.Add(new Person
{
firstName = c.firstname, //ok
lastName = c.Name, //ok
// contactItems is an array of ContactItem
// so it can be null that's why I get null exception
// when it's actually null
phone = c.address.contactItems.Where( ci => ci.contactType == ContactType.PHONE).First().contactText
}
);
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过不要取消null.如果数组为null,我没有得到告诉LINQ不处理的机制.
phone = c.address.contactItems.Where( ci => ci != null && ci.contactType == ContactType.PHONE).First().contactText
Run Code Online (Sandbox Code Playgroud) 我必须像1M实体一样处理以构建事实.应该有大约相同数量的结果事实(100万).
我遇到的第一个问题是批量插入,实体框架很慢.所以我在实体框架中使用了这种最快的插入方式(来自SLauma的回答).我可以在一分钟内快速插入实体,大约100K.
我遇到的另一个问题是缺乏处理所有内容的内存.所以我已经"分页"了处理过程.为了避免内存不足,如果我从我的100万结果事实中列出一个列表,我会得到.
我的问题是即使使用分页,内存也总是在增长,我不明白为什么.每批后没有释放内存.我认为这很奇怪,因为我在循环的每次迭代中获取重建构建事实并将它们存储到DB中.一旦循环完成,那些应该从内存中释放出来.但它看起来并不是因为每次迭代后都没有释放内存.
在我挖掘更多之前,你能否告诉我你是否看错了什么?更具体地说,为什么在迭代循环之后没有释放内存.
static void Main(string[] args)
{
ReceiptsItemCodeAnalysisContext db = new ReceiptsItemCodeAnalysisContext();
var recon = db.Recons
.Where(r => r.Transacs.Where(t => t.ItemCodeDetails.Count > 0).Count() > 0)
.OrderBy( r => r.ReconNum);
// used for "paging" the processing
var processed = 0;
var total = recon.Count();
var batchSize = 1000; //100000;
var batch = 1;
var skip = 0;
var doBatch = true;
while (doBatch)
{ // list to store facts processed during the batch
List<ReconFact> …Run Code Online (Sandbox Code Playgroud) 是否可以编写一个简单的专用Web工作程序,以便它连续处理某些内容并仅在客户端请求时发送其状态.
我到目前为止所做的客户文件:
<script>
// spawn a worker
var worker = new Worker('basic-worker.js');
// decide what to do when the worker sends us a message
worker.onmessage = function(e){
document.getElementById('result').textContent = e.data;
};
</script>
<html>
<head></head>
<body>
<p>The Highest prime number discovered so far : <outpout id="result"></output></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
工人档案:
var n = 0;
search: while (true) {
n += 1;
for (var i = 2; i <= Math.sqrt(n); i += 1)
if (n % i == 0)
continue search;
// found …Run Code Online (Sandbox Code Playgroud) 使用angular我想创建一个选择列表,其值带有我选择的id(对象的实际id属性),我想用ng-model指令正确绑定它.
这是我尝试过的:
<select ng-model="selectedPersonId"
ng-options="p.id as p.name for p in People track by p.id"></select>
$scope.People = [
{ name : "Fred", id : 1 },
{ name : "Joe", id : 2 },
{ name : "Sandra", id : 3 },
{ name : "Kacey", id : 4 },
{ name : "Bart", id : 5 }
];
$scope.setTo1 = function(){
$scope.selectedPersonId = 1;
}
Run Code Online (Sandbox Code Playgroud)
这里选择选项值是正确的值(值是人的人的id),文本是正确的.但绑定不起作用,所以如果我设置$ scope.selectedPersonId的值,选择不会反映在列表中.
我知道我可以让它像这样工作:
<select ng-model="selectedPersonId"
ng-options="p.id as p.name for p in People"></select>
Run Code Online (Sandbox Code Playgroud)
它工作我可以设置$ …
c# ×4
javascript ×2
angularjs ×1
arrays ×1
data-binding ×1
ext3 ×1
filesystems ×1
html5 ×1
knockout.js ×1
linq ×1
linux ×1
ntfs ×1
null ×1
selectlist ×1
web-worker ×1
windows ×1