Skip to content

Commit f8f1eca

Browse files
committed
Support UpdateByQuery fluent method taking only selector
This aligns with 5.x. Provide an overload to UpdateByQuery() that accepts only the selector, setting Indices and Types to T.
1 parent 1ecaf8d commit f8f1eca

File tree

7 files changed

+11210
-11172
lines changed

7 files changed

+11210
-11172
lines changed

src/CodeGeneration/ApiGenerator/Domain/CsharpMethod.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,17 @@ public IEnumerable<Constructor> DescriptorConstructors()
191191
{
192192
doc += "\r\n" + string.Join("\t\t\r\n", cp.Select(p => $"///<param name=\"{p.Key}\"> this parameter is required</param>"));
193193
}
194-
var c = new Constructor { Generated = $"public {m}({par}) : base({routing}){{}}", Description = doc };
194+
195+
var generated = $"public {m}({par}) : base({routing}){{}}";
196+
197+
// Add typeof(T) as the default type when only index specified
198+
if ((m == "UpdateByQueryDescriptor") && cp.Count() == 1 && !string.IsNullOrEmpty(this.RequestTypeGeneric))
199+
{
200+
var generic = this.RequestTypeGeneric.Replace("<", "").Replace(">", "");
201+
generated = $"public {m}({par}) : base({routing}.Required(\"type\", (Types)typeof({generic}))){{}}";
202+
}
203+
204+
var c = new Constructor { Generated = generated, Description = doc };
195205
ctors.Add(c);
196206
}
197207
if (IsDocumentPath && !string.IsNullOrEmpty(this.DescriptorTypeGeneric))

0 commit comments

Comments
 (0)