/// <summary>
        /// 得到一个已经存在的记录的临时表
        /// </summary>
        /// <param name="ownerKeyBuilder"></param>
        /// <param name="existedKeys"></param>
        /// <param name="mapping"></param>
        /// <returns></returns>
        private string GetInnerExistedObjsSql(IConnectiveSqlClause ownerKeyBuilder, IConnectiveSqlClause existedKeys, ORMappingItemCollection mapping)
        {
            ConnectiveSqlClauseCollection connective = new ConnectiveSqlClauseCollection(LogicOperatorDefine.And);

            connective.Add(ownerKeyBuilder);

            string endTimeFieldName = GetPropertyFieldName("VersionEndTime", mapping);

            WhereSqlClauseBuilder veBuilder = new WhereSqlClauseBuilder();

            veBuilder.AppendItem(endTimeFieldName, DBTimePointActionContext.MaxVersionEndTime);

            connective.Add(veBuilder);
            connective.Add(existedKeys);

            return(string.Format("SELECT * FROM {0} WHERE {1}", this.GetTableName(default(T), mapping), connective.ToSqlString(TSqlBuilder.Instance)));
        }
        private static WhereSqlClauseBuilder GetExistedKeysBuilder(IConnectiveSqlClause ownerKeyBuilder, T obj, ORMappingItemCollection mapping)
        {
            WhereSqlClauseBuilder keyBuilder = ORMapping.GetWhereSqlClauseBuilderByPrimaryKey(obj, mapping);

            if (obj.VersionStartTime == DateTime.MinValue)
            {
                keyBuilder.IfExists(GetPropertyFieldName("VersionStartTime", mapping),
                                    item =>
                {
                    item.IsExpression = true;
                    item.Data         = DBTimePointActionContext.CurrentTimeTSqlVarName;
                });
            }

            foreach (string ownerKey in ownerKeyBuilder.GetFields())
            {
                keyBuilder.Remove(item => ((SqlClauseBuilderItemUW)item).DataField == ownerKey);
            }

            return(keyBuilder);
        }
        /// <summary>
        /// 准备Where的子句,填写了VersionStartTime。在插入操作时,VST应该是MinValue。否则应该是最后一条记录的时间
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="mapping"></param>
        /// <param name="builder"></param>
        /// <returns></returns>
        private IConnectiveSqlClause ModifyTimeFieldsInWhereBuilder(T obj, ORMappingItemCollection mapping, WhereSqlClauseBuilder builder)
        {
            string startTimeFieldName = GetPropertyFieldName("VersionStartTime", mapping);
            string endTimeFieldName   = GetPropertyFieldName("VersionEndTime", mapping);

            if (builder.Exists(item => ((SqlClauseBuilderItemIUW)item).DataField == startTimeFieldName) == false)
            {
                builder.AppendItem(startTimeFieldName, obj.VersionStartTime);
            }

            builder.Remove(b => ((SqlClauseBuilderItemIUW)b).DataField == endTimeFieldName);
            builder.AppendItem(endTimeFieldName, DBTimePointActionContext.MaxVersionEndTime);

            return(builder);
        }