This project is read-only.
To try this sample you should have a SQL Azure account.
It is better to use a separate SQL azure server.

To create the federated database for this samples use sql scripts from the SQL directory:
1. First of all create the root database named FedRoot (can be changed in the web.config).
2. Then create federation.
3. Then create federated tables and other objects.
4. Create root table in the root database.
5. Populate root database table with data.
6. Populate federation members with data.
7. Split federation members.
8. Alter the connection strings in web.config files.

Code notes:
Federation.svc – OData service based on reflection data provider,
ServiceModel.cs – service model,
FederatedOData.cs – used to redirect queries to a federation member,
Query.cs – IQueryable implementation base class,
ExpressionFixingVisitor.cs – fixes incompatibilities in expressions between WCF Data Services and EF,
FederationExpressionVisitor.cs – this visitor examines an expression for a distribution key value,
FederationRootAttribute – marks the root collection entity type (see below),
FederationKeyAttribute – assigns the distribution key to each entity type,


There are 3 entities in the sample: State, County and City.
All corresponding tables are federated.
The States is the root collection. Its key is the distribution key. The corresponding table exists in the federation root also and contains all records from all members.
Each query should contain a filter by StateID except queries to the root collection (States).

Valid queries:
http://sqlfederation.cloudapp.net/Federation.svc/States
http://sqlfederation.cloudapp.net/Federation.svc/States(8589934592L)
http://sqlfederation.cloudapp.net/Federation.svc/States(8589934592L)/Counties
http://sqlfederation.cloudapp.net/Federation.svc/Counties(StateID=8589934592L,ID=8589934593L)/Cities
http://sqlfederation.cloudapp.net/Federation.svc/States?$filter=StateID eq 8589934592L and Name eq 'MD'
http://sqlfederation.cloudapp.net/Federation.svc/States(8589934592L)?$expand=Counties/Cities
http://sqlfederation.cloudapp.net/Federation.svc/States?$select=StateID

Invalid queries:
http://sqlfederation.cloudapp.net/Federation.svc/Counties
http://sqlfederation.cloudapp.net/Federation.svc/Cities

Empty result:
http://sqlfederation.cloudapp.net/Federation.svc/States?$expand=Counties

Last edited Feb 15, 2012 at 8:11 PM by mglukhankov, version 1

Comments

No comments yet.