我对mvvm和mvvm light很新,但我想我理解它的一般概念.我不明白的是,如果我想打开一个新窗口,但该窗口需要来自调用者的数据将这些数据传递到新窗口的最佳做法是什么?如果我将数据传递给构造函数,那么这意味着我需要在后面的代码中将代码传递给视图模型.我不能使用消息传递,因为它不是基本数据.提前致谢.
我正在使用Asp.net 5.0 mvc6,我想使用entityframework 6,因为7还没有完全编码,我已经能够让它做除了迁移之外的一切.
当我输入enable-migration,add-migration或update-datatabase时,我得到了
enable-migration : The term 'enable-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ enable-migration
+ ~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (enable-migration:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Run Code Online (Sandbox Code Playgroud)
我很确定这些命令不在PowerShell中.但我确实发现%userdir%.dnx\packages\EntityFramework\_6.1.3\tools中有工具.稍微研究一下migrate.exe,我发现它们告诉我它只适用于proj文件,因此无法使用新设置.
我也尝试在dbcontext的构造函数中使用此代码进入编程路径,我有:
var configuration = new MigrationConfiguration();
var migrator = new DbMigrator(configuration);
migrator.Configuration.TargetDatabase = new DbConnectionInfo(nameOrConnectionString, …Run Code Online (Sandbox Code Playgroud) 所以我花了几周时间研究如何通过ajax从服务器获取pdf,然后将其显示给客户端.我需要这样做的原因是用户不能直接在服务器上转到pdf,因为他们不会提供令牌来传递安全性,但我可以使用javascript.使用以下代码,我能够得到我所期望的:
var xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.responseType = 'arraybuffer';
xhr.setRequestHeader("token", token.value);
xhr.onload = function (e) {
if (this.status == 200) {
var file = new Blob([this.response], { type: 'application/pdf' });
var fileURL = URL.createObjectURL(file);
window.open(fileURL, '_blank');
}
};
xhr.send();
Run Code Online (Sandbox Code Playgroud)
然而,当我尝试以这样的角度做这个确切的事情时(我正在做这个东西的一半,所以两者中的标题匹配):
var config = {
url: url,
method: 'GET',
responseType: 'arraybuffer',
headers: {
'Accept':'*/*',
"token": token.value
}
}
$http(config)
.success(function (response) {
var file = new Blob([response], { type: 'application/pdf' });
var fileURL = URL.createObjectURL(file);
window.open(fileURL, '_blank')
}); …Run Code Online (Sandbox Code Playgroud) c# ×2
angularjs ×1
asp.net-core ×1
javascript ×1
mvvm ×1
mvvm-light ×1
powershell ×1
typescript ×1
wpf ×1