コード例 #1
0
        ///<summary>
        /// For a given value e.g. a Guid Identifier '{......}' this will build up a primary key object that can be used to
        /// load the business object from the Data store (see Business Object loader GetBusinessObjectByValue)
        /// This can only be used for business objects that have a single property for the primary key
        /// (i.e. non composite primary keys)
        ///</summary>
        ///<param name="classDef">The Class definition of the Business Object to load</param>
        ///<param name="idValue">The value of the primary key of the business object</param>
        ///<returns>the BOPrimaryKey if this can be constructed else returns null</returns>
        public static BOPrimaryKey CreateWithValue(ClassDef classDef, object idValue)
        {
            var primaryKeyDef = (PrimaryKeyDef)ClassDefHelper.GetPrimaryKeyDef(classDef, ClassDef.ClassDefs);

            if (primaryKeyDef.IsCompositeKey)
            {
                return(null);
            }

            var boPropCol    = classDef.CreateBOPropertyCol(true);
            var boPrimaryKey = primaryKeyDef.CreateBOKey(boPropCol) as BOPrimaryKey;

            if (boPrimaryKey != null)
            {
                boPrimaryKey[0].Value = idValue;
            }
            return(boPrimaryKey);
        }
コード例 #2
0
ファイル: BOPrimaryKey.cs プロジェクト: kevinbosman/habanero
        ///<summary>
        /// For a given value e.g. a Guid Identifier '{......}' this will build up a primary key object that can be used to
        /// load the business object from the Data store (see Business Object loader GetBusinessObjectByValue)
        /// This can only be used for business objects that have a single property for the primary key
        /// (i.e. non composite primary keys)
        ///</summary>
        ///<param name="classDef">The Class definition of the Business Object to load</param>
        ///<param name="idValue">The value of the primary key of the business object</param>
        ///<returns>the BOPrimaryKey if this can be constructed else returns null</returns>
        public static BOPrimaryKey CreateWithValue(ClassDef classDef, object idValue)
        {
            var primaryKeyDef = (PrimaryKeyDef) ClassDefHelper.GetPrimaryKeyDef(classDef, ClassDef.ClassDefs);
            if (primaryKeyDef.IsCompositeKey) return null;

            var boPropCol = classDef.CreateBOPropertyCol(true);
            var boPrimaryKey = primaryKeyDef.CreateBOKey(boPropCol) as BOPrimaryKey;
            if (boPrimaryKey != null)
            {
                boPrimaryKey[0].Value = idValue;
            }
            return boPrimaryKey;
        }