コード例 #1
0
ファイル: Soql.cs プロジェクト: valery-shinkevich/sooda
 public static SoqlBooleanExpression CollectionFor(CollectionManyToManyInfo coll, SoodaObject parent)
 {
     SoqlPathExpression needle = new SoqlPathExpression(coll.GetItemClass().GetFirstPrimaryKeyField().Name);
     RelationInfo relation = coll.GetRelationInfo();
     SoqlQueryExpression query = new SoqlQueryExpression();
     query.SelectExpressions.Add(new SoqlPathExpression(relation.Table.Fields[coll.MasterField].Name));
     query.SelectAliases.Add(string.Empty);
     query.From.Add(relation.Name);
     query.FromAliases.Add(string.Empty);
     query.WhereClause = FieldEquals(relation.Table.Fields[1 - coll.MasterField].Name, parent);
     SoqlExpressionCollection haystack = new SoqlExpressionCollection();
     haystack.Add(query);
     return new SoqlBooleanInExpression(needle, haystack);
 }
コード例 #2
0
        private void AutoDetectCollections(SchemaInfo si)
        {
            int counter = 0;
            foreach (ClassInfo ci in si.Classes)
            {
                foreach (FieldInfo fi in ci.LocalTables[0].Fields)
                {
                    if (fi.ReferencedClass != null)
                    {
                        ArrayList al = new ArrayList();
                        if (fi.ReferencedClass.Collections1toN != null)
                        {
                            al.AddRange(fi.ReferencedClass.Collections1toN);
                        }
                        CollectionOnetoManyInfo coll = new CollectionOnetoManyInfo();
                        coll.Name = "CollectionOf" + ci.Name + "" + counter++;
                        coll.ClassName = ci.Name;
                        coll.ForeignFieldName = fi.Name;
                        al.Add(coll);

                        fi.ReferencedClass.Collections1toN = (CollectionOnetoManyInfo[])al.ToArray(typeof(CollectionOnetoManyInfo));
                        // ci.Collections1toN
                    }
                }
            }
            foreach (RelationInfo ri in si.Relations)
            {
                CollectionManyToManyInfo mm;
                ArrayList al;

                al = new ArrayList();
                if (ri.Table.Fields[0].ReferencedClass.CollectionsNtoN != null)
                    al.AddRange(ri.Table.Fields[0].ReferencedClass.CollectionsNtoN);

                mm = new CollectionManyToManyInfo();
                mm.Name = "CollectionOf" + ri.Table.Fields[1].ReferencedClass.Name + "" + counter++;
                mm.Relation = ri.Name;
                mm.ForeignField = ri.Table.Fields[0].Name;
                al.Add(mm);

                ri.Table.Fields[0].ReferencedClass.CollectionsNtoN = (CollectionManyToManyInfo[])al.ToArray(typeof(CollectionManyToManyInfo));

                al = new ArrayList();
                if (ri.Table.Fields[1].ReferencedClass.CollectionsNtoN != null)
                    al.AddRange(ri.Table.Fields[1].ReferencedClass.CollectionsNtoN);

                mm = new CollectionManyToManyInfo();
                mm.Name = "CollectionOf" + ri.Table.Fields[0].ReferencedClass.Name + "" + al.Count;
                mm.Relation = ri.Name;
                mm.ForeignField = ri.Table.Fields[1].Name;
                al.Add(mm);

                ri.Table.Fields[1].ReferencedClass.CollectionsNtoN = (CollectionManyToManyInfo[])al.ToArray(typeof(CollectionManyToManyInfo));

            }
        }