Example #1
0
        /// <summary>
        /// 复制一个MappingItem
        /// </summary>
        /// <returns></returns>
        public ORMappingItem Clone()
        {
            ORMappingItem newItem = new ORMappingItem();

            newItem.dataFieldName        = this.dataFieldName;
            newItem.propertyName         = this.propertyName;
            newItem.subClassPropertyName = this.subClassPropertyName;
            newItem.isIdentity           = this.isIdentity;
            newItem.primaryKey           = this.primaryKey;
            newItem.length     = this.length;
            newItem.isNullable = this.isNullable;
            newItem.subClassTypeDescription = this.subClassTypeDescription;
            newItem.bindingFlags            = this.bindingFlags;
            newItem.defaultExpression       = this.defaultExpression;
            newItem.memberInfo    = this.memberInfo;
            newItem.enumUsage     = this.enumUsage;
            newItem.isUpdateWhere = this.isUpdateWhere;
            return(newItem);
        }
Example #2
0
        private static DbParameter DoInsertUpdateSqlWithParamBuilder <T>(SqlClauseBuilderIUW builder, ORMappingItem item, T graph)
        {
            DbParameter param = TSqlBuilder.Instance.CreateDbParameter();

            if (item.IsIdentity == false)
            {
                object data = GetValueFromObject(item, graph);

                if ((data == null || data == DBNull.Value || (data != null && data.Equals(TypeCreator.GetTypeDefaultValue(data.GetType())))) &&
                    string.IsNullOrEmpty(item.DefaultExpression) == false)
                {
                    builder.AppendItem(item.DataFieldName, item.DefaultExpression, SqlClauseBuilderBase.EqualTo, true);
                }
                else
                {
                    builder.AppendItem(item.DataFieldName, data);
                }
            }

            return(param);
        }