我有一个名为Address的类,其中包含以下属性:
<form id="form" >
<input style="width:200;margin-top:5px" type="text" class="form-control" id="code" name="installer2_code" placeholder="Enter Code">
<input type="submit" href="#" style="margin-top:5px" name="installer2_btn" class="btn btn-success" id="form" onclick =" sendForm(event);" value="Enter">
</form>
<script>
$('#form').on('click', function(e){
e.preventDefault();
var name = $(#code).val(),
$.ajax({
type: 'post',
url: 'header_php.php',
});
});
</script>
计划是将AddressType作为以下任一项的枚举:客户,供应商或位置,以及KeyId作为来自客户,供应商或位置的外键。
这是可以使用Entity Framework正确完成的,还是应该创建3个单独的类CustomerAddress,VendorAddress,LocationAddress。
答案 0 :(得分:0)
您需要从单个数据库表生成实体继承结构。可以通过使用每种类型的方法
来实现这一点将公共属性分组为&#34; Base&#34;实体,然后使用鉴别器(在您的情况下为AddressType
)来专门化对象。
答案 1 :(得分:0)
我看起来你有三个表Customer,Vendor或Location,你想为每个表保存地址。
然后,不应在Address表中添加AddressType,而应将每个表中的AddressID作为外键包含在内,并且每个表中必须包含一个地址导航属性。