在非 xml 环境中针对 linq 解耦通用键值访问
早上好。
我不是受过教育的计算机科学家,所以请忽略任何可疑的术语滥用。
在我的框架中,名为 Record 的基本表单将 RecordDetail 作为对话框打开。例如,RecordClient 扩展了 Record 并包含客户端数据和与客户端相关的子数据的选项卡式列表,而 RecordDetail 完全基于存储为针对 DataContext 的自定义属性存储的反射和显示覆盖来扩展一个子数据行以进行详细编辑。 Record 是应用程序的子类,但我认为不需要子类 RecordDetail。除了在列出的子项中显示外键编辑之外,此方法有效。
我必须使用ObjectListView和Linq;我无法使用 WPF/XML。因为我对非连续数据库连接执行序列化技巧,所以当我克隆数据来管理状态时,我会丢失外键对象。 ObjectListView 需要外键对象来显示和一般邪恶。我了解 Hibernate,但 Linq 让我不知所措:
在 RecordDetail 的对话框关闭后,我如何从 Record 中访问外键对象 - 不耦合框架和特定于应用程序的类?
也就是说,
Type rowType = row.GetType();
IDomain workDamnit = (IDomain)dataContextReflectedFromRowType.GetTable(rowType).Where(x => x.PrimaryKey == 1).SingleOrDefault();
“PrimaryKey”包装主键属性,并且失败发生在“GetTable”、“Where”和“SingleOrDefault”之间。
在这个美好的周日早晨,任何观点都值得赞赏。
good morning.
i am not a computer scientist by education, so please overlook any shady term abuse.
in my framework, a base form called Record opens form RecordDetail as dialog. for example, RecordClient extends Record and contains client data and tabbed lists of client-relevant child data, and RecordDetail expands one child data row for detailed editing based wholly on reflection and display overrides stored as custom attributes used against DataContext. Record is subclassed for the application, but i see no need to subclass RecordDetail. this works except for the display of foreign key edits in the listed children.
i must use ObjectListView and Linq; i cannot use WPF/XML. because i do the serialization trick for non-continuous database connectivity, i lose foreign key objects when i clone data to manage state. ObjectListView needs the foreign key object for display and general wickedness. i know Hibernate, but Linq leaves me at a loss:
how might i access the foreign key object from within Record after its dialog to RecordDetail closes - without coupling framework and application-specific classes?
that is,
Type rowType = row.GetType();
IDomain workDamnit = (IDomain)dataContextReflectedFromRowType.GetTable(rowType).Where(x => x.PrimaryKey == 1).SingleOrDefault();
where "PrimaryKey" wraps the primary key attribute, and the fail happens between "GetTable", "Where" and "SingleOrDefault".
any perspective appreciated on this fine sunday morning.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
实际上,我决定将外键对象叔叔并缓存在由子类记录表单访问的池中。
actually, i've decided to uncle under and cache the foreign key objects in a pool accessed by the subclassed Record forms.