1
我正在如何在LightSwitch中執行以下操作。我的partial void tblStaffExtendeds_Updating(tblStaffExtended entity)
期間「攔截」的實體,然後從本地ldap
拉一些數據,並試圖建立實體的屬性之一爲特定的值,就像這樣:LightSwitch實體:更新外鍵屬性的值
partial void tblStaffExtendeds_Updating(tblStaffExtended entity)
{
string ldapPath = @"LDAP://DC=myLDAP,DC=myLDAP";
string user = entity.GPEmployeeID.ToString();
string[] props = {
ActiveDirectoryInfo.strings.DISPLAYNAME, ActiveDirectoryInfo.strings.EMAIL,
ActiveDirectoryInfo.strings.LOGONALIAS, ActiveDirectoryInfo.strings.PHONE,
ActiveDirectoryInfo.strings.OFFICE, ActiveDirectoryInfo.strings.TITLE,
ActiveDirectoryInfo.strings.GPEMPLOYEEID
};
var propResults = ActiveDirectoryInfo.UserPropertySearchByGPEmpID(user, ldapPath, props);
entity.tblAdminStaffType.StaffType = propResults[ActiveDirectoryInfo.strings.TITLE];
entity.WorkEmail = propResults[ActiveDirectoryInfo.strings.EMAIL];
entity.UserID = propResults[ActiveDirectoryInfo.strings.LOGONALIAS];
entity.WorkPhone = propResults[ActiveDirectoryInfo.strings.PHONE];
}
現在像WorkEmail
領域和WorkPhone
這工作正常,因爲那些屬性只是strings
,這就是我從LDAP
得到的。
但是我該怎麼去設置StaffType
這是對Admin Table條目的引用? LDAP返回一個string
,它與Admin Table上的描述相匹配,但是我需要將實體設置爲正確的ID,我假設。
有沒有辦法做到這一點,通過將描述與我的String
從LDAP
匹配來創建「查找」方法來找到管理員表中的ID?