Esempio n. 1
0
 protected virtual void Init()
 {
     start = 0;
     end   = 0;
     // for instance, only manage index for one field query using 'equal'
     if (classInfo.HasIndex() && query.HasCriteria() && CanUseIndex(query.GetCriteria(
                                                                        )))
     {
         NeoDatis.Tool.Wrappers.List.IOdbList <string> fields = query.GetAllInvolvedFields(
             );
         if (fields.IsEmpty())
         {
             useIndex = false;
         }
         else
         {
             int[] fieldIds = GetAllInvolvedFieldIds(fields);
             classInfoIndex = classInfo.GetIndexForAttributeIds(fieldIds);
             if (classInfoIndex != null)
             {
                 useIndex = true;
             }
         }
     }
     // Keep the detail
     details = GetDetails();
 }
Esempio n. 2
0
        /// <exception cref="System.Exception"></exception>
        public virtual void TestReuse()
        {
            string baseName = GetBaseName();

            NeoDatis.Odb.ODB odb = Open(baseName);
            System.Collections.Generic.IList <NeoDatis.Odb.Test.VO.Login.Profile> profiles = new
                                                                                             System.Collections.Generic.List <NeoDatis.Odb.Test.VO.Login.Profile>();
            profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p1", new NeoDatis.Odb.Test.VO.Login.Function
                                                                    ("f1")));
            profiles.Add(new NeoDatis.Odb.Test.VO.Login.Profile("p2", new NeoDatis.Odb.Test.VO.Login.Function
                                                                    ("f2")));
            NeoDatis.Odb.Test.Query.Criteria.ClassB cb = new NeoDatis.Odb.Test.Query.Criteria.ClassB
                                                             ("name", profiles);
            odb.Store(cb);
            odb.Close();
            odb = Open(baseName);
            NeoDatis.Odb.Test.VO.Login.Profile p = (NeoDatis.Odb.Test.VO.Login.Profile)odb.GetObjects
                                                       (typeof(NeoDatis.Odb.Test.VO.Login.Profile)).GetFirst();
            NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query = odb.CriteriaQuery(typeof(
                                                                                              NeoDatis.Odb.Test.Query.Criteria.ClassB), NeoDatis.Odb.Core.Query.Criteria.Where
                                                                                          .Equal("profiles", p));
            NeoDatis.Odb.Impl.Core.Query.Criteria.EqualCriterion ec = (NeoDatis.Odb.Impl.Core.Query.Criteria.EqualCriterion
                                                                       )query.GetCriteria();
            try
            {
                NeoDatis.Odb.Objects <NeoDatis.Odb.Test.Query.Criteria.ClassB> l = odb.GetObjects(
                    query);
            }
            catch (System.Exception e)
            {
                AssertTrue(NeoDatis.Tool.Wrappers.OdbString.ExceptionToString(e, true).IndexOf("1063"
                                                                                               ) != -1);
            }
            odb.Close();
        }
Esempio n. 3
0
 /// <summary>Take the fields of the index and take value from the query</summary>
 /// <param name="ci">The class info involved</param>
 /// <param name="index">The index</param>
 /// <param name="query"></param>
 /// <returns>The key of the index</returns>
 public static NeoDatis.Tool.Wrappers.OdbComparable ComputeKey(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                               ci, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index, NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                               query)
 {
     string[] attributesNames = ci.GetAttributeNames(index.GetAttributeIds());
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values = query.GetCriteria
                                                                          ().GetValues();
     return(BuildIndexKey(index.GetName(), values, attributesNames));
 }
Esempio n. 4
0
 public override System.IComparable ComputeIndexKey(NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfo
                                                    ci, NeoDatis.Odb.Core.Layers.Layer2.Meta.ClassInfoIndex index)
 {
     NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery q = (NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery
                                                              )query;
     NeoDatis.Odb.Core.Layers.Layer2.Meta.AttributeValuesMap values = q.GetCriteria().
                                                                      GetValues();
     // if values.hasOid() is true, this means that we are working of the full object,
     // the index key is then the oid and not the object itself
     if (values.HasOid())
     {
         return(new NeoDatis.Odb.Core.Query.SimpleCompareKey(values.GetOid()));
     }
     return(NeoDatis.Odb.Core.Query.Execution.IndexTool.ComputeKey(classInfo, index, (
                                                                       NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery)query));
 }
Esempio n. 5
0
 public ValuesCriteriaQuery(NeoDatis.Odb.Impl.Core.Query.Criteria.CriteriaQuery query
                            ) : this(query.GetFullClassName(), query.GetCriteria())
 {
 }