我在C#中使用实体框架代码优先,我有许多实体具有用于跟踪的相同列.我使用的列是Active,IsDeleted,CreatedBy,ModifiedBy,DateCreated和DateUpdated.将这些属性添加到我想要跟踪的每个实体似乎很乏味.我想有一个我的实体可以继承的基类,如下所示.
public abstract class TrackableEntity
{
public bool Active { get; set; }
public bool IsDeleted { get; set; }
public virtual User CreatedBy { get; set; }
public virtual User ModifiedBy { get; set; }
public DateTime DateCreated { get; set; }
public DateTime DateModified { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然后我可以从我的实体中的这个类继承以获得这些属性,并且当生成数据库时,它将为每个实体提供这些列.
public class UserProfile : TrackableEntity, IValidatableObject
{
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; } …Run Code Online (Sandbox Code Playgroud) 我有以下功能,但当单选按钮被选为否时它不会模糊.有什么想法吗?
表格元素:
<td>
Email: Yes? <input type="radio" name="emailquest" value="true" checked>
No? <input type="radio" name="emailquest" value="false">
</td>
<td>
<input type="text" name="email">
</td>
Run Code Online (Sandbox Code Playgroud)
脚本:
<script>
$(document).ready(function(){
$("#emailquest").blur(function(){
if ($(this).val() != true)
$("#email").attr("disabled","disabled");
else
$("#email").removeAttr("disabled");
});
});
</script>
Run Code Online (Sandbox Code Playgroud)