Example #1
0
 /// <summary>
 /// Gets the object key by pk.
 /// </summary>
 /// <param name="pk">The pk.</param>
 /// <returns></returns>
 public ObjectKey GetObjectKeyByPk(string pk)
 {
     string[] tokens = pk.Split('!');
     if (tokens.Length == 1)
     {
         return(new ObjectKey(this.EntityType.Name, pk));
     }
     else
     {
         List <KeyValuePair <string, object> > keyPairs = new List <KeyValuePair <string, object> >();
         int          i     = 0;
         IObjectProxy proxy = ObjectProxyFactory.GetByType(this.EntityType);
         foreach (IMetamodelField field in this.Fields)
         {
             if (field.IsPrimaryKey)
             {
                 keyPairs.Add(new KeyValuePair <string, object>(field.Name, this.ChangeType(tokens[i], proxy.GetPropertyType(field.Name))));
                 i++;
             }
         }
         return(new ObjectKey(this.EntityType.Name, keyPairs));
     }
 }