这有意义吗?MyValue 可以是“真”或“假”
它不应该是 Stringcomparison.OrdinalIgnoreCase 吗?
MyValue.Equals("true", StringComparison.CurrentCultureIgnoreCase))
Run Code Online (Sandbox Code Playgroud) TemplateController:
这工作:
return PartialView("_Create");
Run Code Online (Sandbox Code Playgroud)
但这不起作用:
return PartialView();
Run Code Online (Sandbox Code Playgroud)
asp.net mvc约定实际上应检查具有控制器名称=>"模板"的View文件夹,并检查View与action =>"Create"的名称相同.
这对返回View()有效.为什么返回PartialView()不仅仅考虑下划线?
我使用Automapper或手动映射,它不起作用.
ReleaseViewModel的所有数据必须首先在Release中,因为它随数据访问层填充.90%的模特都是这样的.为什么重复一切的开销?
KISS原理和过度工程怎么样?
当然,每个工具都适合其适当的任务,但我经常读到,在asp.net mvc中不使用ViewModel是NO-GO.
在哪里划线?当我们从模型中区分到50%,75%或99%时,我应该使用ViewModels吗?
我有一个模型发布:
public class Release
{
public int Id { get; set; }
public string Name { get; set; }
public string Author { get; set; }
public DateTime CreatedAt { get; set; }
public int FailedTestsCount { get; set; }
public int SucceededTestsCount { get; set; }
public int SumTestsCount
{
get
{
return SucceededTestsCount + FailedTestsCount;
}
}
public int SumTestingTime { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
一个viewmodel ReleaseViewModel:
public class ReleaseViewModel
{
[HiddenInput(DisplayValue …Run Code Online (Sandbox Code Playgroud) 我创建了一个默认的 web api 项目,其中至少加载了这 2 个媒体格式化程序。两者都用于相同的内容类型:
FormUrlEncodedMediaTypeFormatter: application/x-www-form-urlencoded
JQueryMvcFormUrlEncodedFormatter: application/x-www-form-urlencoded
Run Code Online (Sandbox Code Playgroud)
当我用enctype="application/x-www-form-urlencoded"它做一个简单的 http post 表单时,它只适用于JQueryMvcFormUrlEncodedFormatter,这意味着我发送的复杂对象在服务器端不为空。
当我JQueryMvcFormUrlEncodedFormatter在应用程序启动时删除格式化程序并再次执行简单的 http post 表单时,我希望它再次工作,但它没有。
我得到一个异常,没有加载适当的格式化程序。
那不是真的-实际上-
为什么它不起作用?
聚苯乙烯
我发现这就是区别:
– System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter, for handling HTML form URL-encoded data
– System.Web.Http.ModelBinding.JQueryMvcFormUrlEncodedFormatter, for handling model-bound HTML form URL-encoded data
Run Code Online (Sandbox Code Playgroud)
但我不明白其中的区别!
我什至不使用 jquery 来发布我的表单:
<form role="form" method="post" action="api/values" enctype="application/x-www-form-urlencoded">
<input type="text" class="form-control" name="firstName" placeholder="Enter first name">
<input type="text" class="form-control" name="lastName" placeholder="Enter last name">
<button type="submit" class="btn btn-default">Submit</button>
</form>
Run Code Online (Sandbox Code Playgroud) 对于TestType,我想同时包含导航道具Schoolclass和Subject。
我可以这样做:
.Include(t => t.TestType)
.ThenInclude(x => x.Subject)
Run Code Online (Sandbox Code Playgroud)
但不是:
.Include(t => t.TestType)
.ThenInclude(x => x.Subject)
.ThenInclude(x => x.Schoolclass)
Run Code Online (Sandbox Code Playgroud)
因此,我尝试了一些技巧,并且奏效了:
我将TestType包含了2次...
var test = await context.Tests.Where(t => t.SchoolyearId == schoolyearId)
.Include(t => t.TestType)
.ThenInclude(x => x.Subject)
.Include(t => t.TestType)
.ThenInclude(x => x.Schoolclass)
.AsNoTracking()
.ToListAsync();
Run Code Online (Sandbox Code Playgroud)
这是官方的方法还是有更好的方法?
更新
public class TestType
{
public TestType()
{
Tests = new HashSet<Test>();
}
public int Id { get; set; }
public string Name { get; set; }
public int Weight { get; set; }
public ISet<Test> …Run Code Online (Sandbox Code Playgroud) 如何在ADO.NET中以编程方式创建oracle数据库,并使用userId + password为其创建模式,这样我就可以转到我不喜欢的工具sql oracle开发人员工具,我只需创建一个连接进入:
我们使用SecurityMode.None运行NetTcpBinding.
现在我们还想要加密发送的数据.将SecurityMode设置为Transport似乎还不够,因为虽然服务器已启动,但客户端无法再连接到服务器(在此更改之前有效).
我还需要改变什么?
从我的集成测试:
// Act
Stopwatch w = new Stopwatch();
w.Start();
userService.Create(userDTO);
w.Stop();
public void Create(UserDTO userDTO)
{
var user = userDTO.ToEntity();
_context.Entry(user).State = EntityState.Added;
_context.SaveChanges();
}
Run Code Online (Sandbox Code Playgroud)
6,2秒做"sql插入"是疯了.我已经看到应用程序用户在第一次打开他们使用全年的项目时抱怨.所以每天都要等6秒......
我认为EF6的预热时间有所改善?
我能做些什么来改善这种悲惨的行为吗?
我有一个路由网址,如:
/departments/:id/employees/assign'
Run Code Online (Sandbox Code Playgroud)
当我导航到上述网址时:
this._router.navigate(['/departments/:id/employees/assign', id]);
Run Code Online (Sandbox Code Playgroud)
然后 angular 总是将传递的 id 附加到 url 的末尾,但这不是我想要的。
当我尝试这个时
this._router.navigate(['/departments/:id/employees/assign', {id: id}]);
Run Code Online (Sandbox Code Playgroud)
我在浏览器中得到这个网址:
http://localhost:4200/departments/%3Aid/employees/assign;id=1
Run Code Online (Sandbox Code Playgroud)
我希望网址在浏览器中: /departments/1/employees/assign
我需要改变什么?
为什么红色 div 没有垂直居中?
我的笔:http : //codepen.io/helloworld/pen/aWWgBK?editors=1000
<table style="border:1px solid black" class="table">
<thead>
<th>selected</th>
<th>Name</th>
</thead>
<tbody>
<tr>
<td class="align-middle"><input type="checkbox"></td>
<td style="display: flex; align-items: center;">
<div style="background:red;"> this text should be vertically aligned in the center of the table cell </div>
</td>
<td class="align-middle">
<div class="btn-group">
<button class="btn btn-primary">Speichern</button>
<button type="button" class="btn btn-secondary">Abbrechen</button>
</div>
</td>
<td>
<ul>
<li>item 1</li>
<li>item 2</li>
<li>item 3</li>
<li>item 4</li>
<li>item 5</li>
<li>item 6</li>
</ul>
</td>
</tr>
</tbody>
</table>Run Code Online (Sandbox Code Playgroud)