|
@@ -727,14 +727,86 @@ namespace TEAMModelOS.SDK.Module.AzureCosmosDB.Implements
|
|
|
{
|
|
|
if (DocumentCollectionDict.TryGetValue(CollectionName, out DocumentCollection collection))
|
|
|
{
|
|
|
- // collection = await InitializeCollection(CollectionName, "");
|
|
|
- StringBuilder sql = new StringBuilder("select * from " + CollectionName + " c where 1=1 ");
|
|
|
+ // collection = await InitializeCollection(CollectionName, "");
|
|
|
+ /* StringBuilder sql = new StringBuilder("select * from " + CollectionName + " c where 1=1 ");
|
|
|
+ if (dict != null)
|
|
|
+ {
|
|
|
+ foreach (string key in dict.Keys)
|
|
|
+ {
|
|
|
+ sql.Append(GenSql(dict[key], key));
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+ StringBuilder sql = new StringBuilder("select value(c) from c");
|
|
|
if (dict != null)
|
|
|
{
|
|
|
- foreach (string key in dict.Keys)
|
|
|
+
|
|
|
+ string Join = " join ";
|
|
|
+ string instring = "in ";
|
|
|
+ Dictionary<string, string> keyValues = new Dictionary<string, string>();
|
|
|
+ StringBuilder ps = new StringBuilder();
|
|
|
+ int heada = 0;
|
|
|
+ string[] sqlHead = new string[] { "A", "B", "C", "D", "E", "F" };
|
|
|
+ int kslength = 0;
|
|
|
+ foreach (KeyValuePair<string, object> item in dict)
|
|
|
{
|
|
|
- sql.Append(GenSql(dict[key], key));
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+ string[] ks = item.Key.Split("[*]");
|
|
|
+
|
|
|
+ if (ks.Length > 1)
|
|
|
+ {
|
|
|
+ kslength += ks.Length;
|
|
|
+ if (kslength < (7 + heada))
|
|
|
+ {
|
|
|
+ StringBuilder sqlitem = new StringBuilder();
|
|
|
+ for (int i = 0; i < ks.Length - 1; i++)
|
|
|
+ {
|
|
|
+
|
|
|
+ //Console.WriteLine(ks[i]);
|
|
|
+ if (i == 0)
|
|
|
+ {
|
|
|
+ sqlitem.Append(Join);
|
|
|
+ string a = sqlHead[heada] + index;
|
|
|
+ sqlitem.Append(a + " ");
|
|
|
+ //keyValues.Add(ks[i], a);
|
|
|
+ keyValues[ks[i]] = a;
|
|
|
+ sqlitem.Append(instring);
|
|
|
+ sqlitem.Append("c.");
|
|
|
+ sqlitem.Append(ks[i]);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ sqlitem.Append(Join + " ");
|
|
|
+ string a = sqlHead[heada] + index;
|
|
|
+ sqlitem.Append(a + " ");
|
|
|
+ //keyValues.Add(ks[i], a);
|
|
|
+ keyValues[ks[i]] = a;
|
|
|
+ sqlitem.Append(instring);
|
|
|
+ sqlitem.Append(keyValues[ks[i - 1]]);
|
|
|
+ sqlitem.Append(ks[i]);
|
|
|
+ }
|
|
|
+ index += 1;
|
|
|
+ }
|
|
|
+ // Console.WriteLine(sqlitem);
|
|
|
+ sql.Append(sqlitem);
|
|
|
+ string s;
|
|
|
+ s = "and " + sqlHead[heada] + (ks.Length - 2) + ks[index] + " = " + "\"" + item.Value.ToString() + "\"";
|
|
|
+ ps.Append(s);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ throw new BizException("数组总共深度不能超过5层",ResponseCode.PARAMS_ERROR);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ ps.Append(GenSql(dict[item.Key], item.Key));
|
|
|
+ }
|
|
|
+ heada += 1;
|
|
|
}
|
|
|
+ sql.Append(" where 1=1 ").Append(ps);
|
|
|
}
|
|
|
FeedOptions queryOptions;
|
|
|
if (collection.PartitionKey.Paths.Count > 0)
|