动态实体SQL&外键 [英] Dynamic Entity SQL & Foreign Keys

查看:74
本文介绍了动态实体SQL&外键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi All
在我的应用程序中,我正在使用Entity SQL来处理动态EntityObjects。
现在我遇到了以下情况的问题:
想象一下我有EntityObject,就像Organization一样,具有Person1(联系人)和Person2(cheaf人)以及cource对应引用(Person1Reference和Person2Reference)等属性。

从UI我得到一个Dictionary< string,object>(列名 - 列值)更新具体的EnitityObject。
如果是"我们的"组织我收到两个KeyValuePairs:[ContactId,10]和[CheafId,20]。

如何确定我应该使用哪个导航属性(Organization.Person1Reference或Organization.Person2Reference)来更新它的EntityKey,基于列名和值。

Hi All
In my application I'm using Entity SQL to work with dynamic EntityObjects.
Now I've got into an issue with the following situation:
Imagine I have EntityObject, like Organization, that has properties like Person1(contact person) and Person2(cheaf person) and of cource corresponding references (Person1Reference and Person2Reference).

From the UI I get a Dictionary<string, object>(column name - column value) to  update concrete EnitityObject. 
In case of "our" Organization I receive two KeyValuePairs: [ContactId, 10] and [CheafId, 20].

How Do I determine what navigation property should I use (Organization.Person1Reference or Organization.Person2Reference) to update it's EntityKey, based on column name and value.

推荐答案

听起来你想要使用简单的if / else语句,不是吗?例如,如果(key ==" ContactId"){
//设置Person1Reference
},则if(key ==" CheafId"){
// set Person2Reference
}

从您的电子邮件看起来像一个任意的映射,所以蛮力的方法似乎是合理的......
Sounds like you want to use a simple if/else statement, no? E.g.
if (key == "ContactId") {
 //set Person1Reference
} else if (key == "CheafId") {
 // set Person2Reference
}

Seems like an arbitrary mapping, from your email, so a brute force approach seems reasonable...


这篇关于动态实体SQL&amp;外键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆