我有一个简单的问题(我希望如此)。我有一个返回字符串作为结果的服务。格式是这样的:
" Test1: 关联已被接受。\nTest2: 关联已被接受。\n" "
在客户端(我使用的是 Angular 1.5.x),我将该字符串放入一个对象中(比如变量 $scope.alert.message)。之后我想在模态中打印该字符串。我的 html 是:
<script type="text/ng-template" id="infoTemplate.html">
<div class="modal-header left" ng-class="['div-' + alert.type, closeable ? 'alert-dismissible' : null]">
<h3 class="modal-title" id="modal-title">Info</h3>
</div>
<div class="modal-body" id="modal-body">
<img class="imm-info" ng-class="['imm-' + alert.type, closeable ? 'alert-dismissible' : null]" />
<p class="col-sm-10 col-sm-offset-2">{{alert.message}}</p><button class="col-sm-3 col-sm-offset-5 btn " ng-class="['button-' + alert.type, closeable ? 'alert-dismissible' : null]" ng-click="cancel()">OK</button>
</div>
</script>
Run Code Online (Sandbox Code Playgroud)
您可以看到“{{alert.message}}”。我的问题是我的消息“不显示”字符 '\n'。所以它不会创建多于一行。这里的一个例子:
我不知道我是否遗漏了某些东西......无论如何:
例如,您可以看到具有属性'HomeTeam'='Forest Green Rovers'的对象具有state ='Unchanged'.无论如何,在我的情况下,所有实体都"保持不变".所以,如果我是正确的,saveChanges不应该尝试在我的表中插入那些,但这就是它发生的事情:
主键已被违反,但EF不应该尝试添加此记录(属性为HomeTeam ='Forest Green Rovers'),因为它是'Unchanged',对吗?
为什么EF这样做?
实体:
{
using System;
using System.Collections.Generic;
public partial class MatchInfo
{
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public MatchInfo()
{
this.Sport = "Soccer";
this.OddsInfoes1X2 = new HashSet<OddsInfo1X2>();
this.Odds1X2Movements = new HashSet<OddsMovement>();
this.OddsInfoOverUnders = new HashSet<OddsInfoOverUnder>();
this.OddsMovementOverUnders = new HashSet<OddsMovementOverUnder>();
this.HistoryResults = new HashSet<HistoryResult>();
}
public string League { get; set; }
public System.DateTime Date { get; set; }
public string HomeTeam { get; set; }
public string AwayTeam { get; set; }
public string …Run Code Online (Sandbox Code Playgroud)