我有一个表让我们说FavoriteFruits,有NAME,有FRUIT,和GUID列.该表已经填充了名称和水果.所以我们说:
NAME FRUIT GUID
John Apple NULL
John Orange NULL
John Grapes NULL
Peter Canteloupe NULL
Peter Grapefruit NULL
Run Code Online (Sandbox Code Playgroud)
好的,现在我想GUID用新的GUID(使用NEWID())更新列,但我希望GUID每个不同的名称具有相同的名称.所以我希望所有人都John Smiths拥有相同的东西GUID,我希望两者Peters都有相同的东西GUID,但GUID与用于约翰斯的那个不同.所以现在它看起来像这样:
NAME FRUIT GUID
John Apple f6172268-78b7-4c2b-8cd7-7a5ca20f6a01
John Orange f6172268-78b7-4c2b-8cd7-7a5ca20f6a01
John Grapes f6172268-78b7-4c2b-8cd7-7a5ca20f6a01
Peter Canteloupe e3b1851c-1927-491a-803e-6b3bce9bf223
Peter Grapefruit e3b1851c-1927-491a-803e-6b3bce9bf223
Run Code Online (Sandbox Code Playgroud)
我可以在更新语句中执行此操作而无需使用游标吗?如果是这样,请举个例子?
多谢你们...
我刚开始学习设计模式,我有两个与装饰师有关的问题......
我想知道为什么装饰器模式表明装饰器实现了它装饰的组件的所有公共方法?
装饰器类不能只用于提供额外的行为,然后具体组件(传递给它)只是用于调用其他所有内容吗?
其次,如果要装饰的具体组件没有抽象装饰器也可以派生出来的基类怎么办?
提前致谢!
好的,这很难说,所以这里......
我正在使用MS SQL Server 2008 R2.我有一个临时表,可以说有两个已经填充的列.我想根据前两列的值填充第三个空列.我想要做的是为col1和col2的每个匹配组合创建一个guid(使用NEWUID()).这是一个视觉示例:
让我说我有一个最初看起来像这样的临时表:
Name Activity SpecialId
James Running
James Running
James Walking
John Running
John Running
John Walking
Run Code Online (Sandbox Code Playgroud)
我想让它更新新的GUID,使它看起来像这样:
Name Activity SpecialId
James Running SOMEFAKEGUID_1
James Running SOMEFAKEGUID_1
James Walking SOMEFAKEGUID_2
John Running SOMEFAKEGUID_3
John Running SOMEFAKEGUID_3
John Walking SOMEFAKEGUID_4
Run Code Online (Sandbox Code Playgroud)
请注意如何为每个匹配对创建新的GUID.因此,James/Running组合对所有James/Running组合具有相同的GUID ...而John/Running也具有与John/Running组合相同的GUID,但与James/Running组合的GUID不同.
我试图尽可能清楚地表明这一点,但希望这不是很清楚!
有人可以告诉我SQL查询会是什么样子,以便使用正确的GUID更新临时表吗?
提前致谢.
瑞安
我尝试使用反射复制以下 C# 代码:
UserProfileManager userProfileManager = new UserProfileManager(ServerContextGoesHere);
UserProfile userProfile = null;
userProfile = userProfileManager.GetUserProfile(@"somedomain\someuser");
userProfile["PictureUrl"].Value = "This is where I want to update the value using reflection!";
userProfile.Commit();
Run Code Online (Sandbox Code Playgroud)
使用反射,除了我尝试在 UserProfile 对象上设置“PictureUrl”索引属性的行之外,我可以让所有内容正常工作。使用反编译器时,索引属性如下所示:
public UserProfileValueCollection this[string strPropName]
Run Code Online (Sandbox Code Playgroud)
这是我的代码,使用反射来实现与上面相同的效果,请注意 TODO 注释,我需要在其中设置 PictureUrl 索引属性的值:
Assembly userProfileAssembly;
var windowsFolderPath = Environment.GetEnvironmentVariable("windir");
var pathToServerAssembly = string.Format(@"{0}\assembly\GAC_MSIL\Microsoft.Office.Server.UserProfiles\14.0.0.0__71e9bce111e9429c\Microsoft.Office.Server.UserProfiles.dll", windowsFolderPath);
try
{
userProfileAssembly = Assembly.LoadFrom(pathToServerAssembly);
}
catch (FileNotFoundException)
{
// Assembly wasn't found, so eject.
return;
}
var userProfileManagerClass = userProfileAssembly.GetType("Microsoft.Office.Server.UserProfiles.UserProfileManager");
if (userProfileManagerClass == null) return;
var userExistsMethod …Run Code Online (Sandbox Code Playgroud) c# reflection sharepoint indexed-properties sharepoint-userprofile