当前位置: 首页>>代码示例>>C#>>正文


C# IEntity.GetField方法代码示例

本文整理汇总了C#中IEntity.GetField方法的典型用法代码示例。如果您正苦于以下问题:C# IEntity.GetField方法的具体用法?C# IEntity.GetField怎么用?C# IEntity.GetField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IEntity的用法示例。


在下文中一共展示了IEntity.GetField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateSelectFromLevelQuery

        private static SelectStatement CreateSelectFromLevelQuery(IEntity rootEntity, DbRelation recursiveRelation, SearchCondition leafFilter, int level, LevelQuerySelectList itemsToSelect)
        {
            if (level > Settings.GenericHierarchicalQueryExecutorMaxLevel)
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, Messages.GenericHierarchicalQueryExecutor_MaxLevelReachedFormat, Settings.GenericHierarchicalQueryExecutorMaxLevel));

            // Target level table must be child table because that is the table which is used in leafFilter.
            // If leaf filter is used then the we must ensure that proper table name is used for target table.
            IDbTable targetLevelTable;
            if (leafFilter != null && !leafFilter.IsEmpty)
                targetLevelTable = recursiveRelation.Child;
            else
                targetLevelTable = rootEntity.Table.Clone("L" + level);

            SelectStatement selectFromTargetLevel = new SelectStatement(targetLevelTable);
            CreateSelectListItems(itemsToSelect, targetLevelTable, selectFromTargetLevel);

            if (leafFilter != null && !leafFilter.IsEmpty)
                selectFromTargetLevel.Where.Add(leafFilter);

            IDbTable prevLevel = targetLevelTable;
            for (int parentLevel = level - 1; parentLevel >= 0; parentLevel--)
            {
                IDbTable nextLevel = rootEntity.Table.Clone("L" + parentLevel);
                DbRelation joinLevels = JoinLevelsInSubTree(prevLevel, nextLevel, recursiveRelation);
                selectFromTargetLevel.Relations.Add(joinLevels, false, false);
                prevLevel = nextLevel;
            }

            IDbTable subTreeRoot = prevLevel;
            foreach (IDbColumn rootPkPart in subTreeRoot.PrimaryKey)
                selectFromTargetLevel.Where.Add(rootPkPart, rootEntity.GetField(rootPkPart));

            return selectFromTargetLevel;
        }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:34,代码来源:GenericHierarchicalQueryExecutor.cs

示例2: CreateCompositePk

        private static object[] CreateCompositePk(IEntity child, DbRelation fk)
        {
            // Child and parent columns in the relation are in the same order.
            // However, that order may not match the order of PK definition in the parent's IDbTable class.
            // Thus, the FK values may have to be reordered to be used as PK.
            IDbColumn[] orderedPkFields = fk.Parent.PrimaryKey.ToArray();
            object[] pk = new object[orderedPkFields.Length];
            int nullValCount = 0;
            for (int idxOrderedPkPart = 0; idxOrderedPkPart < orderedPkFields.Length; idxOrderedPkPart++)
            {
                IDbColumn currPkField = orderedPkFields[idxOrderedPkPart];
                int positionOfCurrentPkColumnInRelation = IndexOfColumnInArray(fk.ParentPrimaryKey, currPkField.ColumnName);
                IDbColumn currFkField = fk.ChildForeignKey[positionOfCurrentPkColumnInRelation];
                object fkPart = child.GetField(currFkField);
                pk[idxOrderedPkPart] = fkPart;

                if (fkPart == null)
                    nullValCount++;
            }

            bool fkIsSet = (nullValCount == 0);
            if (!fkIsSet)
            {
                bool allFkFieldsAreNull = (nullValCount == orderedPkFields.Length);
                if (allFkFieldsAreNull)
                    pk = null;
                else
                    throw new ArgumentException(Messages.PkUtil_FkMustBeCompleteOrNull, "child");
            }

            return pk;
        }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:32,代码来源:PkUtil.cs

示例3: CreateSingleFieldPk

 private static object[] CreateSingleFieldPk(IEntity child, DbRelation fk)
 {
     object[] pk;
     // Complex algorithm not required if simple FK is used.
     object fkVal = child.GetField(fk.ChildForeignKey[0]);
     pk = (fkVal != null) ? new object[] { fkVal } : null;
     return pk;
 }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:8,代码来源:PkUtil.cs

示例4: Equals

        /// <summary>
        /// Checks for equality of entities. <b>IEquatable[IEntity]</b> implementation.
        /// </summary>
        /// <param name="other">Entity to compare to.</param>
        /// <returns>True if all fields in objects match.</returns>
        public bool Equals(IEntity other)
        {
            if (other == null)
                return false;

            if (this.table.TableName != other.Table.TableName ||
                this.table.Columns.Count != other.Table.Columns.Count)
                return false;

            foreach (IDbColumn item in other.Table.Columns)
            {
                if (this._Table.Columns.GetByColumnName(item.ColumnName) == null)
                    return false;

                if (this.GetField(item) != other.GetField(item))
                    return false;
            }

            return true;
        }
开发者ID:lordfist,项目名称:FistCore.Lib,代码行数:25,代码来源:EntityModelBase.cs


注:本文中的IEntity.GetField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。