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


C# Reference.SetReferenceEnd2CollectionFetchMode方法代码示例

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


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

示例1: ProcessOtherEndOfReference

        private void ProcessOtherEndOfReference(AssociationInformation info, Entity toEntity, Reference reference)
        {
            var potentialOtherEnds =
                associationInformation.Where(inf => inf.ThisEntityName == info.OtherEntityName
                && inf.OtherEntityName == info.ThisEntityName);

            AssociationInformation otherEndInfo = null;

            if (potentialOtherEnds.Count() == 1)
                otherEndInfo = potentialOtherEnds.FirstOrDefault();
            else if (potentialOtherEnds.Count() > 1)
            {
                foreach (var pot in potentialOtherEnds)
                {
                    if (info.ForeignKeyColumnNames.Count == pot.ForeignKeyColumnNames.Count)
                    {
                        bool found = true;

                        for (int i = 0; i < info.ForeignKeyColumnNames.Count; i++)
                        {
                            if (pot.ForeignKeyColumnNames[i] != info.ForeignKeyColumnNames[i])
                            {
                                found = false;
                                break;
                            }
                        }
                        if (found)
                        {
                            otherEndInfo = pot;
                            break;
                        }
                    }
                }
                //log.Error("While processing references, ");
            }
            reference.Entity2 = toEntity;

            if (info.ForeignKeyColumnNames.Count == 0 && otherEndInfo != null)
            {
                info.ForeignKeyColumnNames = otherEndInfo.ForeignKeyColumnNames;
                info.ForeignKeyBelongsToThisTable = false;
            }
            if (otherEndInfo == null)
            {
                reference.End2Enabled = false;
                Cardinality cardinality;

                if (info.AssociationTableName != null && !string.IsNullOrEmpty(info.AssociationTableName.TableName))
                    cardinality = Cardinality.Many;
                else if (info.HasUniqueConstraint)
                    cardinality = Cardinality.One;
                else
                    cardinality = Cardinality.Many;

                reference.Cardinality2 = cardinality;
            }
            else
            {
                reference.End2Enabled = true;
                reference.End2Name = otherEndInfo.PropertyName;
                reference.Cardinality2 = otherEndInfo.Cardinality;
                reference.SetEnd2AssociationType(otherEndInfo.AssociationType);
                reference.SetEnd2IndexColumnName(otherEndInfo.IndexColumn);
                reference.SetEnd2SqlWhereClause(otherEndInfo.WhereClause);
                reference.SetReferenceEnd2FetchMode(otherEndInfo.FetchMode);
                reference.SetReferenceEnd2CollectionFetchMode(otherEndInfo.CollectionFetchMode);
                reference.SetReferenceEnd2Insert(otherEndInfo.Insert);
                reference.SetReferenceEnd2Update(otherEndInfo.Update);
                reference.SetReferenceEnd2Inverse(otherEndInfo.Inverse);
                reference.SetReferenceEnd2Cascade(otherEndInfo.Cascade);
                reference.SetReferenceEnd2CollectionCascade(otherEndInfo.CollectionCascade);
                reference.SetReferenceEnd2Lazy(otherEndInfo.CollectionLazy);
                reference.SetReferenceEnd2OrderByIsAsc(otherEndInfo.OrderByIsAsc);

                if (!string.IsNullOrWhiteSpace(otherEndInfo.OrderByColumnName))
                {
                    var orderByProp = toEntity.Properties.SingleOrDefault(p => p.MappedColumn() != null && p.MappedColumn().Name.Equals(otherEndInfo.OrderByColumnName, StringComparison.InvariantCultureIgnoreCase));

                    if (orderByProp != null)
                        reference.SetReferenceEnd2OrderByProperty(orderByProp.Name);
                }
                //reference.SetReferenceEnd2OrderByProperty(otherEndInfo.OrderByColumnName);
                associationInformation.Remove(otherEndInfo);
            }
        }
开发者ID:uQr,项目名称:Visual-NHibernate,代码行数:85,代码来源:ReferenceLoader.cs


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