I get an exception if i Fill in ManagedDataType.Text as propertydatatype.
The exception is: The variant type 1 cannot be mapped to managed data type Text.
I use this example as follows:
MapManagedProperty(
"f0d3d197-0d2a-41c9-947b-66dfa0c98d99", "BACCODE",
ManagedDataType.Text , "BACCODE");
My method:
private
staticvoid
MapManagedProperty(string PropertyId, string PropertyNaam,
ManagedDataType propertydatatype, string MappingKolomNaam)
{
Guid cPropGUID = newGuid(PropertyId);
string cPropName = PropertyNaam;
int vType = Convert.ToInt32(propertydatatype);string mPropName = MappingKolomNaam;
SearchContext context;
string strURL = urlusing (SPSite site = newSPSite(strURL))
{
context =
SearchContext.GetContext(site);
}
Schema sspSchema = newSchema(context);
ManagedPropertyCollection properties = sspSchema.AllManagedProperties;
ManagedProperty mProp = properties[mPropName];
Mapping newMapping = newMapping(cPropGUID, cPropName,
vType, mProp.PID);
MappingCollection mappings = mProp.GetMappings();
if (mappings.Contains(newMapping))
{
Console.WriteLine("Toewijzing mislukt: Aangevraagde toewijzing bestaat al.");
return;
}
mappings.Add(newMapping);
mProp.SetMappings(mappings);
Console.WriteLine(cPropName + "Verkende eigenschap toegewezen aan " + mProp.Name + " eigenschap.");
return;
}