Exemple #1
0
        public string GetChildSelects(CslaObjectInfo info, Criteria crit, bool searchWhereClause)
        {
            bool collType = IsCollectionType(info.ObjectType);

            if (collType)
            {
                info = FindChildInfo(info, info.ItemType);
            }

            StringBuilder sb    = new StringBuilder();
            var           first = true;

            foreach (ChildProperty childProp in info.GetAllChildProperties())
            {
                CslaObjectInfo childInfo = FindChildInfo(info, childProp.TypeName);
                if (!collType && childInfo != null && childProp.LoadingScheme != LoadingScheme.SelfLoad)
                {
                    if (!first)
                    {
                        sb.Append(Environment.NewLine);
                    }
                    else
                    {
                        first = false;
                    }

                    sb.Append(GetSelect(childInfo, crit, true, searchWhereClause));
                    sb.Append(GetChildSelects(childInfo, crit, searchWhereClause));
                }
            }

            return(NormalizeNewLineAtEndOfFile(sb.ToString()));
        }
Exemple #2
0
        public static CslaObjectInfo FindParentObject(this CslaObjectInfo info)
        {
            CslaObjectInfo parentInfo = null;

            if (string.IsNullOrEmpty(info.ParentType))
            {
                // no parent specified; find the object whose child is this object
                foreach (var cslaObject in info.Parent.CslaObjects)
                {
                    foreach (var childProperty in cslaObject.GetAllChildProperties())
                    {
                        if (childProperty.TypeName == info.ObjectName)
                        {
                            parentInfo = cslaObject;
                        }
                    }
                    if (parentInfo != null)
                    {
                        break;
                    }
                }
            }
            else
            {
                parentInfo = info.Parent.CslaObjects.Find(info.ParentType);
            }

            if (parentInfo != null)
            {
                if (parentInfo.ItemType == info.ObjectName)
                {
                    return(parentInfo.FindParentObject());
                }

                if (parentInfo.GetAllChildProperties().FindType(info.ObjectName) != null)
                {
                    return(parentInfo);
                }

                /*if (parentInfo.GetCollectionChildProperties().FindType(info.ObjectName) != null)
                 *  return parentInfo;*/
            }

            return(null);
        }
Exemple #3
0
        public CslaObjectInfo FindParent(CslaObjectInfo childInfo)
        {
            CslaObjectInfo info = null;

            if (String.IsNullOrEmpty(childInfo.ParentType))
            {
                foreach (CslaObjectInfo o in childInfo.Parent.CslaObjects)
                {
                    foreach (ChildProperty p in o.GetAllChildProperties())
                    {
                        if (p.TypeName == childInfo.ObjectName)
                        {
                            info = o;
                        }
                    }
                    if (info != null)
                    {
                        break;
                    }
                }
            }
            else
            {
                info = childInfo.Parent.CslaObjects.Find(childInfo.ParentType);
            }
            if (info != null)
            {
                if (info.ItemType == childInfo.ObjectName)
                {
                    return(FindParent(info));
                }
                else if (info.GetAllChildProperties().FindType(childInfo.ObjectName) != null)
                {
                    return(info);
                }
                else if (info.GetCollectionChildProperties().FindType(childInfo.ObjectName) != null)
                {
                    return(info);
                }
            }
            return(null);
        }
        public CslaObjectInfo[] GetChildItems(CslaObjectInfo info)
        {
            List <CslaObjectInfo> list = new List <CslaObjectInfo>();

            foreach (ChildProperty cp in info.GetAllChildProperties())
            {
                CslaObjectInfo ci = FindChildInfo(info, cp.TypeName);
                if (ci != null)
                {
                    if (IsCollectionType(ci.ObjectType))
                    {
                        ci = FindChildInfo(info, ci.ItemType);
                    }
                    if (ci != null)
                    {
                        list.Add(ci);
                    }
                }
            }
            return(list.ToArray());
        }