/// <summary> /// 构造视图模型以表示所提供的 ContactDetail /// </summary> /// <param name="detail">要为其生成 ViewModel 的详细信息</param> /// <returns>构造的 ViewModel,如果无法生成则为 null</returns> public static ContactDetailViewModel BuildViewModel(ContactDetail detail) { if (detail == null) { throw new ArgumentNullException("detail"); } Email e = detail as Email; if (e != null) { return new EmailViewModel(e); } Phone p = detail as Phone; if (p != null) { return new PhoneViewModel(p); } Address a = detail as Address; if (a != null) { return new AddressViewModel(a); } return null; }
/// <summary> /// 用于向 ContactDetails EntitySet 添加新对象的方法,已弃用。请考虑改用关联的 ObjectSet<T> 属性的 .Add 方法。 /// </summary> public void AddToContactDetails(ContactDetail contactDetail) { base.AddObject("ContactDetails", contactDetail); }