FilterClause of table as query
Is there a way to define a whole query as a filterClause for a table? Example: I have have a table of Contacts. Each conta开发者_运维问答ct belongs to a UserId. For a given user, I want to sync not only his own contacts, but also fetch contacts of users he is connected to. So I am trying to use the provision and code generation tool to fulfill this scenario.
Is the following code even possible?
<SyncTable Name="[Contact]" GlobalName="Contact" SchemaName=""
IncludeAllColumns="true" FilterClause="[side].UserId IN ( @UserId, (select
RepresentsUserId from [Contact] where ConnectionStatus = 5 and UserId = @UserId))">
Although this is valid sql, I am not sure how it is support by sync framework.We are working with the CTP 4 release.
I've used extensive subselects and joins as filterclauses. I'm not sure if your filterclause is 100% correct (I'm no sql wizard, but I'm not sure you can combine a variable and a select in an IN clause), I would write it as follows:
[side].UserId = @UserId OR [side].UserId IN (select RepresentsUserId from [Contact] where ConnectionStatus = 5 and UserId = @UserId)
or maybe even
[side].UserId IN (select @UserId UNION select RepresentsUserId from [Contact] where ConnectionStatus = 5 and UserId = @UserId)
In any case, if your sql is correct, this should work. Subselects and inner joins are supported in sync framework filter clauses.
精彩评论