安装Visual Studio 2017 Professional后,我无法再在Visual Studio 2015 Professional中构建我的ASP.NET Core.我从未在VS2017中打开过这个项目
我明白了
尝试运行项目模型服务器进程(1.0.0-preview3-004056)时发生以下错误.
无法启动该过程.找不到匹配命令dotnet-projectmodel-server的可执行文件
然后我在Visual Studio 2015中创建了一个全新的ASP.NET Core项目,并在加载项目时得到完全相同的消息.
另外,当我想要构建项目时,我得到了
MSB1009:项目文件不存在.
ASP.NET 5项目不会出现同样的问题,因此它仅限于ASP.NET Core
Visual Studio 2017年3月7日更新
如果在下面的答案中添加了一个global.json,则会获得global.json该C:\Program Files\dotnet\sdk\文件夹中存在的任何.net框架版本的错误消息
错误MSB4019找不到导入的项目"C:\ Program Files\dotnet\sdk\XXX\Microsoft\VisualStudio\v14.0\DotNet\Microsoft.DotNet.Props".确认声明中的路径是否正确,以及该文件是否存在于磁盘上.
此外,当关闭Visual Studio并再次重新打开它时,我收到原始错误消息
我的项目中有一个通用存储库.请考虑以下控制器代码段
public class Lookup1Controller : Controller
{
readonly MyDbContext _db;
public Lookup1Controller(MyDbContext dataContext)
{
_db = dataContext;
}
public async Task<IActionResult> Index()
{
IGenericRepository<Lookup1> _repository = new GenericRepository<Lookup1>(_db);
var lookup1s = await _repository.SelectAll();
return View(lookup1s);
}
Run Code Online (Sandbox Code Playgroud)
我认为不需要在我的Generic存储库以及每个控制器中都有我的数据库引用.
我重构它:
public class Lookup1Controller : Controller
{
private IGenericRepository<Lookup1> _repository;
public Lookup1Controller(IGenericRepository<Lookup1> repository)
{
_repository = repository;
}
public async Task<IActionResult> Index()
{
var lookup1s = await _repository.SelectAll();
return View(lookup1s);
}
}
Run Code Online (Sandbox Code Playgroud)
从我读到的内容来看,它更简洁,也是ASP.NET 5的最佳实践.但如果我在浏览器中访问该控制器路径,我将收到以下错误:
InvalidOperationException: Unable to resolve service for type 'MyProject.Data.IGenericRepository`1[MyProject.Models.Lookup1]' while …Run Code Online (Sandbox Code Playgroud) 我想使用急切加载在Entity Framework Core中获得多个嵌套级别的子表.我不认为延迟加载已经实现.
我找到了EF6 的答案.
var company = context.Companies
.Include(co => co.Employees.Select(emp => emp.Employee_Car))
.Include(co => co.Employees.Select(emp => emp.Employee_Country))
.FirstOrDefault(co => co.companyID == companyID);
Run Code Online (Sandbox Code Playgroud)
我的问题是Select在EF Core中无法识别
错误CS1061"Employees"不包含"Select"的定义,也没有扩展方法"Select"接受类型为"Employees"的第一个参数(您是否缺少using指令或程序集引用?)
我包含的命名空间:
using MyProject.Models;
using Microsoft.Data.Entity;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Run Code Online (Sandbox Code Playgroud)
Select在EF Core中有什么替代方案.
我正在使用带有Reactive表单的Angular 5,并且需要使用valueChanges来动态地禁用所需的验证
组件类:
export class UserEditor implements OnInit {
public userForm: FormGroup;
userName: FormControl;
firstName: FormControl;
lastName: FormControl;
email: FormControl;
loginTypeId: FormControl;
password: FormControl;
confirmPassword: FormControl;
...
ngOnInit() {
this.createFormControls();
this.createForm();
this.userForm.get('loginTypeId').valueChanges.subscribe(
(loginTypeId: string) => {
console.log("log this!");
if (loginTypeId === "1") {
console.log("disable validators");
Validators.pattern('^[0-9]{5}(?:-[0-9]{4})?$')]);
this.userForm.get('password').setValidators([]);
this.userForm.get('confirmPassword').setValidators([]);
} else if (loginTypeId === '2') {
console.log("enable validators");
this.userForm.get('password').setValidators([Validators.required, Validators.minLength(8)]);
this.userForm.get('confirmPassword').setValidators([Validators.required, Validators.minLength(8)]);
}
this.userForm.get('loginTypeId').updateValueAndValidity();
}
)
}
createFormControls() {
this.userName = new FormControl('', [
Validators.required,
Validators.minLength(4)
]);
this.firstName = new FormControl('', …Run Code Online (Sandbox Code Playgroud) 我在用 ASP.NET 5 MVC RC1
我的ASP.NET MVC使用的jquery验证插件是默认的ASP.NET 5模板项目使用的标准jquery.validate.js.
/*!
* jQuery Validation Plugin v1.14.0
*
* http://jqueryvalidation.org/
*
* Copyright (c) 2015 Jörn Zaefferer
* Released under the MIT license
*/
Run Code Online (Sandbox Code Playgroud)
和jquery.validation.unobtrusive.js
/*!
** Unobtrusive validation support library for jQuery and jQuery Validate
** Copyright (C) Microsoft Corporation. All rights reserved.
*/
Run Code Online (Sandbox Code Playgroud)
我在下面提供了一个简单的必填字段示例来演示我的问题.
视图模型:
public class TierImportStatusUpdateViewModel
{
[Required]
public string String1 { get; set; }
[Required]
public string String2 { get; set; }
//more fields
}
Run Code Online (Sandbox Code Playgroud)
CSHTML:
@model MyViewModel …Run Code Online (Sandbox Code Playgroud) 我将.net标准类库从Entity Framework Core 1.1升级到Entity Framework 2.0
我试图在针对.net框架4.6.1的实体框架核心类库上运行Add-Migration
Add-Migration MyMigration
Run Code Online (Sandbox Code Playgroud)
但是我得到以下错误
System.IO.FileLoadException:无法加载文件或程序集'System.ValueTuple,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51'或其依赖项之一.定位的程序集的清单定义与程序集引用不匹配.(来自HRESULT的异常:0x80131040)文件名:'System.ValueTuple,Version = 0.0.0.0,Culture = neutral,PublicKeyToken = cc7b13ffcd2ddd51',位于Microsoft的Microsoft.EntityFrameworkCore.Metadata.Conventions.Internal.SharedTableConvention.Apply(InternalModelBuilder modelBuilder). Microsoft的System.Collections.Concurrent.ConcurrentDictionary
2.GetOrAdd(TKey key, Func2 valueFactory 上的Microsoft.EntityFrameworkCore.Infrastructure.ModelSource.CreateModel(DbContext上下文,IConventionSetBuilder conventionSetBuilder,IModelValidator验证器)中的EntityFrameworkCore.Metadata.Conventions.Internal.ConventionDispatcher.ImmediateConventionScope.OnModelBuilt(InternalModelBuilder modelBuilder)Microsoft.Extensions.DependencyInjection.ServiceLookup中的Microsoft.Exntions.DependencyInjection.ServiceLookup.CallSiteVisitor的Microsoft.EntityFrameworkCore.Internal.DbContextServices.get_Model()中的2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor.EntityFrameworkCore.Internal.DbContextServices.CreateModel (). VisitCallSite(IServiceCallSite callSite,TArgument参数) .CallSiteR2.VisitCallSite(IServiceCallSite callSite, TArgument argument) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProvider provider) at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitorMicrosoft的MicrosoftExtensions.DependencyInjection.ServiceProvider.<> c__DisplayClass22_0.b__0(ServiceProvider提供程序)的Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor 2.VisitCallSite(IServiceCallSite callSite,TArgument参数)中的untimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite,ServiceProvider提供程序) Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider上Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()的Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService [T](IServiceProvider提供程序)中的.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider提供程序,类型serviceType). ()Microsoft.EntityFra的Microsoft.EntityFrameworkCore.Infrastructure.AccessorExtensions.GetService [TService](IInfrastructure1 accessor) at Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(Func1工厂),位于Microsoft.EntityFra的Microsoft.EntityFrameworkCore.Design.Internal.DbContextOperations.CreateContext(String contextType)Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase中的Microsoft.EntityFrameworkCore.Design.OperationExecutor.AddMigrationImpl(String name,String outputDir,String contextType)中的meworkCore.Design.Internal.MigrationsOperations.AddMigration(String name,String outputDir,String …
我已安装Visual Studio 2015 Update 1.但是,尽管选择了安装Web应用程序,但它尚未安装.然后我从get.asp.net网站安装了asp.net 5 RC安装程序.
现在,当我想打开我的ASP.net 5项目时,我收到以下消息:
我怎么知道哪一个是最新版本?dnx-clr-win-x86.1.0,0,rc1-final和dnx-clr-win-x86.1.0,0.rc1-update1
以及如何升级现有项目以使用最新项目.
我在使用Visual Studio 2017中的模板创建的Apache Cordova项目中有以下jquery post调用.
$.post("http://localhost:58998/api/product/save", productData)
.done(function (data) {
console.log(data);
});
Run Code Online (Sandbox Code Playgroud)
我在Visual Studio 2017中以调试模式运行项目到Android,模拟到Nexus 4选项
但是我得到了浏览器错误
POST http:// localhost:4400/xhr_proxy?rurl = http%3A // localhost%3A58998/api/product/save 415(不支持的媒体类型)
根据我的理解,xhr_proxy被注入,因为它不喜欢我调用不同的域
我读过你必须安装cordova-plugin-whitelist并调整config.xml
https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-whitelist/
我补充道
<allow-intent href="*" />
<access origin="*" />
Run Code Online (Sandbox Code Playgroud)
只是尝试在没有xhr_proxy的情况下使其工作,但这仍然会产生相同的错误
如何使用jquery执行API帖子并能够使用Visual Studio 2017 Android调试进行调试?
cordova cordova-plugins visual-studio-cordova visual-studio-2017
我正在使用SqlDataReader从SQL Server 2012数据库中获取数据:
SqlConnection connection = (SqlConnection)_db.Database.GetDbConnection();
await connection.OpenAsync();
SqlCommand command = new SqlCommand("dbo.[sp_MyStoredPrc] @InputId=1", connection);
var reader = await command.ExecuteReaderAsync();
if (reader.HasRows)
{
while (reader.Read())
{
int? var1 = (int?)reader["Column1Name"];
}
}
Run Code Online (Sandbox Code Playgroud)
int从数据库读取NULL 字段时,该字段
reader["Column1Name"]为空,因此代码在运行时引发InvalidCastException。
我试过了
reader.GetInt32(reader.GetOrdinal("Column1Name"))
Run Code Online (Sandbox Code Playgroud)
但这会引发System.Data.SqlTypes.SqlNullValueException。
我也尝试过
reader.GetSqlInt32(reader.GetOrdinal("Column1Name"))
Run Code Online (Sandbox Code Playgroud)
返回null,但类型SqlInt32不是int?我想要的。
我最终做了
if (!reader.IsDBNull(reader.GetOrdinal("Column1Name")))
int? var1 = (int?)reader["Column1Name"];
Run Code Online (Sandbox Code Playgroud)
哪个有效。
问题:
有没有比调用该IsDBNull方法更简单的方法?
为什么为什么reader["Column1Name"]返回nulldb 而不是db值为NULL且字段为a int?
我正在使用ASP.NET 5 MVC6 RC1和Visual Studio 2015 Update 1
我想在视图(.cshtml)和actionresult(控制器方法)之间快速导航.
但是我找不到这样的选择
以前的stackoverflow解决方案不起作用
asp.net-core ×3
.net ×1
.net-core ×1
ado.net ×1
ajax ×1
angular ×1
angular5 ×1
asp.net ×1
asp.net-mvc ×1
c# ×1
cordova ×1
dnx ×1
generics ×1
jquery ×1
sql-server ×1
typescript ×1