示例#1
0
		public ViewMap( ObjectMap map, string propertyName, Type propertyType, CustomViewAttribute cv )
		{
			this.map = map;
			this.propertyName = propertyName;
			this.propertyType = propertyType;
			this.cv = cv;
			if( map != null && cv.NavigateUrlFormat != null )
			{
				string[] keys = map.GetPrimaryKeyNames( true );
				primaryKeyName = keys[ 0 ];
			}
		}
 public ViewMap(ObjectMap map, string propertyName, Type propertyType, CustomViewAttribute cv)
 {
     this.map          = map;
     this.propertyName = propertyName;
     this.propertyType = propertyType;
     this.cv           = cv;
     if (map != null && cv.NavigateUrlFormat != null)
     {
         string[] keys = map.GetPrimaryKeyNames(true);
         primaryKeyName = keys[0];
     }
 }
示例#3
0
        /// <summary>
        /// Obtain a new key for the specified object instance. The returned key will contain the
        /// primary keys of the given instance.
        /// </summary>
        /// <param name="broker">The optional PersistenceBroker instance to use for obtaining the
        /// ObjectMap for the supplied object instance. If this parameter is null, Gentle will try
        /// to infer the broker from the object instance. If that fails, it will use the default
        /// provider.</param>
        /// <param name="key">An optional existing key to add the values to</param>
        /// <param name="isPropertyKeys">False is key indexers are column names, true for property names</param>
        /// <param name="instance">The object instance whose property values will be used</param>
        /// <returns>A key instance containing the primary key values of the given object instance</returns>
        public static Key GetKey(PersistenceBroker broker, Key key, bool isPropertyKeys, object instance)
        {
            // try to infer broker from instance
            if (broker == null && instance is IBrokerLock)
            {
                broker = (instance as IBrokerLock).SessionBroker;
            }
            // WARNING/TODO if broker is null here and no ObjectMap yet exists for the type,
            // the DefaultProvider will be used to create the ObjectMap
            ObjectMap map = ObjectFactory.GetMap(broker, instance);

            return(GetKey(broker, key, isPropertyKeys, instance, map.GetPrimaryKeyNames(isPropertyKeys)));
        }