First of all, thanks so much for the library. It's been immensely helpful for many projects so far, much better than dealing with CAML strings for sure.
So I'm expecting I'm doing something silly here, but here's the story anyway. Working on CAMLEX 3.3.
I've a pretty typical use case - a simple enough query with a bunch of derivatives. To reduce code, I'm using the dynamic queries syntax to add to the existing query.
So an example base query:
var simple = CamlexNET.Camlex.Query()
.Where(
p => p["Hello"] != null
);
... and another query to combine:
var success = CamlexNET.Camlex.Query()
.WhereAny(
simple.ToString(),
p => p["Test"] != null
);
Console.WriteLine(success.ToString());
Which gives you an output like this:
<Where>
<Or>
<IsNotNull>
<FieldRef Name="Test" />
</IsNotNull>
<IsNotNull>
<FieldRef Name="Hello" />
</IsNotNull>
</Or>
</Where>
However, this technique doesn't seem to work for more complex queries, such as the following:
var expiryDate = "ExpiryDate";
var commenceDate = "Commence";
var docFolder = "DocFolder";
var ret = CamlexNET.Camlex.Query()
.Where(
p => (p[expiryDate] == null
|| p[expiryDate] > (CamlexNET.DataTypes.DateTime)CamlexNET.Camlex.Today) &&
(p[commenceDate] == null
|| p[commenceDate] <= (CamlexNET.DataTypes.DateTime)CamlexNET.Camlex.Today)
)
.GroupBy(p => p[docFolder]);
Console.WriteLine(ret.ToString());
You'll see that this generates CAML XML just fine, but when you go to add to it using the same method:
var problem = CamlexNET.Camlex.Query().WhereAny(
ret.ToString(),
p => p["Test"] != null
);
Console.WriteLine(problem.ToString());
The last code chunk returns a "IncorrectCamlException", siting that "Caml specified for tag 'Where' can not be translated to code". I'd suggest it's a bug in the CAML to IQuery translation, because throwing the following XML into camlex-online also fails (yet this is the CAML that is generated by the "ret" query above).
<Where>
<And>
<Or>
<IsNull>
<FieldRef Name="ExpiryDate" />
</IsNull>
<Gt>
<FieldRef Name="ExpiryDate" />
<Value Type="DateTime">
<Today />
</Value>
</Gt>
</Or>
<Or>
<IsNull>
<FieldRef Name="Commence" />
</IsNull>
<Leq>
<FieldRef Name="Commence" />
<Value Type="DateTime">
<Today />
</Value>
</Leq>
</Or>
</And>
</Where><GroupBy>
<FieldRef Name="DocFolder" />
</GroupBy>