Ejemplo n.º 1
0
        //used by IndexMany and DeleteMany
        private string GenerateBulkCommand <T>(IEnumerable <T> @objects, string index, string typeName, string command) where T : class
        {
            objects.ThrowIfEmpty("objects");

            var b = new BulkDescriptor();

            b.FixedPath(index, typeName);
            foreach (var @object in @objects)
            {
                var o = @object;
                if (command == "index")
                {
                    b.Index <T>(bb => bb.Object(o));
                }
                else if (command == "delete")
                {
                    b.Delete <T>(bb => bb.Object(o));
                }
            }

            string json, path;

            this.GenerateBulkPathAndJson(b, out json, out path);
            return(json);
        }
Ejemplo n.º 2
0
        //used by IndexMany and DeleteMany
        private string GenerateBulkCommand <T>(IEnumerable <BulkParameters <T> > @objects, string index, string typeName, string command) where T : class
        {
            objects.ThrowIfEmpty("objects");


            var b = new BulkDescriptor();

            b.FixedPath(index, typeName);
            foreach (var @object in @objects)
            {
                var o = @object;
                if (command == "index")
                {
                    b.Index <T>(bb => bb
                                .Object(o.Document)
                                .Id(o.Id)
                                .Parent(o.Parent)
                                .Percolate(o.Percolate)
                                .Routing(o.Routing)
                                .Timestamp(o.Timestamp)
                                .Ttl(o.Ttl)
                                .Version(o.Version)
                                .VersionType(o.VersionType));
                }
                else if (command == "delete")
                {
                    b.Delete <T>(bb => bb
                                 .Object(o.Document)
                                 .Parent(o.Parent)
                                 .Routing(o.Routing)
                                 .Timestamp(o.Timestamp)
                                 .Ttl(o.Ttl)
                                 .Version(o.Version)
                                 .VersionType(o.VersionType));
                }
            }

            string json, path;

            this.GenerateBulkPathAndJson(b, out json, out path);
            return(json);
        }