コード例 #1
0
ファイル: Model.cs プロジェクト: gonbike/Destrier
        public static Lazy <T> GenerateLazyChildCollectionMember <T>(ChildCollectionMember cm, object instance) where T : class, new()
        {
            var parentReferencedValue = cm.ParentReferencedProperty.GetValue(instance);
            var referencedColumnName  = cm.ReferencedColumnName;

            Func <T> func = () =>
            {
                dynamic queryParams = new System.Dynamic.ExpandoObject();
                ((IDictionary <String, object>)queryParams).Add(referencedColumnName, parentReferencedValue);

                var mi        = typeof(Model).GetMethod("_runLazyChildCollectionQuery", BindingFlags.NonPublic | BindingFlags.Static);
                var genericMi = mi.MakeGenericMethod(cm.CollectionType);
                return(genericMi.Invoke(null, new Object[] { queryParams }) as T);
            };

            return(new Lazy <T>(func));
        }
コード例 #2
0
ファイル: CommandBuilder.cs プロジェクト: gonbike/Destrier
        string _childCollectionParentColumnName(ChildCollectionMember ccm)
        {
            var    lineage = new List <Member>();
            Member member  = ccm.ParentReferencedMember;

            if (member != null)
            {
                lineage.Add(member);
                while (member.Parent != null && !(member.Parent is ChildCollectionMember))
                {
                    lineage.Add(member.Parent);
                    member = member.Parent;
                }
            }

            lineage.Reverse();
            return(String.Join(".", lineage.Select(c => c.Name)));
        }