我有以下代码:
var test = new FallEnvironmentalCondition[] {
new FallEnvironmentalCondition {Id=40,FallId=3,EnvironmentalConditionId=1},
new FallEnvironmentalCondition {Id=41,FallId=3,EnvironmentalConditionId=2},
new FallEnvironmentalCondition {Id=42,FallId=3,EnvironmentalConditionId=3}
};
test.ToList().ForEach(async x => await conn.UpdateAsync(x));
Run Code Online (Sandbox Code Playgroud)
我得到了
InvalidOperationException:连接不支持MultipleActiveResultSets
我不明白我await正在进行每次更新,所以为什么我会收到此错误.
注意:我无法控制连接字符串,因此无法打开MARS.
一个简单的问题,我正在控制台中尝试以下操作
let a = new Proxy(new Date(), {})
Run Code Online (Sandbox Code Playgroud)
我希望能够打电话
a.getMonth();
Run Code Online (Sandbox Code Playgroud)
但它不起作用,它抛出:
未捕获的TypeError:这不是Date对象。在Proxy.getMonth(<匿名>)
在<匿名>:1:3
有趣的是,Chrome浏览器中的自动完成Date功能会建议所有功能a。我想念什么?
以回应方式编辑 @Bergi
我意识到这段代码中除了我的问题之外还有一个错误,但这是我想做的事情:
class myService {
...
makeProxy(data) {
let that = this;
return new Proxy (data, {
cache: {},
original: {},
get: function(target, name) {
let res = Reflect.get(target, name);
if (!this.original[name]) {
this.original[name] = res;
}
if (res instanceof Object && !(res instanceof Function) && target.hasOwnProperty(name)) {
res = this.cache[name] || (this.cache[name] = that.makeProxy(res));
}
return res;
},
set: …Run Code Online (Sandbox Code Playgroud) 我正在获取带有更新时间戳的数据,我想忽略该数据,例如:
public record Person
{
public string LastName,
public string FirstName,
public string MiddleName,
[isThereAnAttributeThatICanPutHere]
public DateTime UpdatedAt
}
Run Code Online (Sandbox Code Playgroud)
C#record自动生成按值比较记录的代码,我想利用该功能,但需要排除一个字段。我知道我可以提供自己的,GetHashCode但这会违背试图保持简单的目的。我也知道我可以与以下内容进行比较:
person1 with {UpdateAt = null} == person2 with {UpdateAt = null}// 这需要 UpdatedAt 可以为空
但这看起来像是不必要的分配。