Esempio n. 1
0
        public Result CreateCollectionIndex(CreateCollectionIndexStatement statement)
        {
            List <KeyValuePair <string, object> > args = new List <KeyValuePair <string, object> >();

            args.Add(new KeyValuePair <string, object>("name", statement.createIndexParams.IndexName));
            args.Add(new KeyValuePair <string, object>("collection", statement.Target.Name));
            args.Add(new KeyValuePair <string, object>("schema", statement.Target.Schema.Name));
            args.Add(new KeyValuePair <string, object>("unique", false));

            if (statement.createIndexParams.Type != null)
            {
                args.Add(new KeyValuePair <string, object>("type", statement.createIndexParams.Type));
            }

            for (int i = 0; i < statement.createIndexParams.Fields.Count; i++)
            {
                var field      = statement.createIndexParams.Fields[i];
                var dictionary = new Dictionary <string, object>();
                dictionary.Add("member", field.Field);
                if (field.Type != null)
                {
                    dictionary.Add("type", field.Type);
                }

                if (field.Required == null)
                {
                    dictionary.Add("required", false);
                }
                else
                {
                    dictionary.Add("required", (bool)field.Required);
                }

                if (field.Options != null)
                {
                    dictionary.Add("options", (ulong)field.Options);
                }

                if (field.Srid != null)
                {
                    dictionary.Add("srid", (ulong)field.Srid);
                }

                if (field.Array != null)
                {
                    dictionary.Add("array", (bool)field.Array);
                }

                args.Add(new KeyValuePair <string, object>("constraint", dictionary));
            }

            return(ExecuteCreateCollectionIndex(XpluginStatementCommand.XPLUGIN_STMT_CREATE_COLLECTION_INDEX, false, args.ToArray()));
        }
Esempio n. 2
0
        public Result CreateCollectionIndex(CreateCollectionIndexStatement statement)
        {
            List <object> args = new List <object>();

            args.Add(statement.Target.Schema.Name);
            args.Add(statement.Target.Name);
            args.Add(statement.createIndexParams.IndexName);
            args.Add(statement.createIndexParams.IsUnique);
            for (int i = 0; i < statement.createIndexParams.DocPaths.Count; i++)
            {
                args.Add(statement.createIndexParams.DocPaths[i]);
                args.Add(statement.createIndexParams.Types[i]);
                args.Add(statement.createIndexParams.NotNulls[i]);
            }

            return(ExecuteCmdNonQuery(XpluginStatementCommand.XPLUGIN_STMT_CREATE_COLLECTION_INDEX, false, args.ToArray()));
        }