I'm trying to a join CustomMeta & PageContents to select a specific page via some metadata that has been set, but I'm getting a "the method join is not supported" error. I think the issue is with my linq statement, as the error happens before anything gets sent to the OData service. But what is the issue exactly? The linq statement looks fine to me:
var pages2 = (from p in cds.PageContents
join m in cds.CustomMetas on p.PageId equals m.ItemId
where m.ItemType==64 && m.KeyName=="SomeKey" && m.StringValue=="SomeValue"
select p).ToList<SDLODataClient.SDLOData.PageContent>();
UPDATE 1
This Tridion OData article has an example of a join but some of the MS Linq to OData articles I'm reading seem to suggest that joins aren't supported in Linq to OData (here)
To my knowledge, LINQ queries against Data Services (OData) does not support several methods. The one you are using is join
is also falls under the same category hence you are seeing the error even though the syntax is very valid from LINQ point of view. join
falls under "Projection and filtering operators" which is not supported query with LINQ against OData .
Here is the link that explains all the unsupported methods (Refer section - Unsupported LINQ Methods)
http://msdn.microsoft.com/en-us/library/ee622463(v=vs.100).aspx
Back to your question, I am not quite how to achieve what you are looking for but I would try the following (you might have to get the results in multiple iterations):
_client.CustomMetas.Where (
m => m.KeyName == "somekey" && m.StringValue == "somevalue" && m.ItemType == 64)
.ToList();
Hope this helps.
Have you tried using the concept of expand ?
In OData service we do not have the join query but there is Expand keyword, wherein two entities (tables) that have a foreign key relationship can be used together to get a result set. It works as follows:
from item in table1.Expand(table2).AsEnumerable()
where (item.property1.Equals("x") & item.table2[0].prop2.Equals("y"))
select item
Here the second entity is exposed as an property of the first entity.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With