在发布此问题之前,我已尝试堆栈上的所有其他解决方案,但没有成功.
我无法使用C#从XElement中删除空的xmlns属性,我尝试了以下代码.
XElement.Attributes().Where(a => a.IsNamespaceDeclaration).Remove();
Run Code Online (Sandbox Code Playgroud)
另一个在这里发帖
foreach (var attr in objXMl.Descendants().Attributes())
{
var elem = attr.Parent;
attr.Remove();
elem.Add(new XAttribute(attr.Name.LocalName, attr.Value));
}
Run Code Online (Sandbox Code Playgroud) 是否可以进行不显眼的验证以使字段成为必需字段,但仅在其他属性发生变化时?
例如
[Required]
public Decimal Income {get; set;}
[Required]
public Decimal Tax {get; set;}
//Required if tax or income changes
public string ChangeReason {get; set;}
Run Code Online (Sandbox Code Playgroud)
我想过有多个后备存储字段并编写自定义验证器来比较这些,但是想知道是否有人有更好的建议?