Take a look at the DomainObjects unit tests, especially DomainObjects.Test.TestFixture.QueryTests and DomainObjects.Test.TestFixture.OuterJoinTests.
Joins are automatically generated by DomainObjects when you specify a path in your Criteria.
For example, see the following unit test:
/// <summary>
/// Tests Criteria.AddEqualTo() with an inner join in the reference path
/// </summary>
[Test]
public void AddEqualToWithInnerJoin()
{
// Create a new instance of Criteria
Criteria criteria = new Criteria();
// Constrain the search to products where the product category name is 'Liquors'.
// Note that, because the '_productCategory' argument represents an object referenced
// by Product, DomainObjects will automatically generate SQL that contains
// an inner join between the PRODUCT table and the referenced PRODUCT_CATEGORY table.
criteria.AddEqualTo(Types.Product._productCategory.Field._name, "Liquors");
// Query the database, i.e., find the list of objects of type Product
// that match the given criteria.
List<Product> results = QueryFacade.FindObjectSet<Product>(criteria);
Assert.Greater(results.Count, 0, "Found some results.");
}
Hope this helps,
Richard
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi There,
Is there an example on how to perform joins.?
Thanks
Hi,
Take a look at the DomainObjects unit tests, especially DomainObjects.Test.TestFixture.QueryTests and DomainObjects.Test.TestFixture.OuterJoinTests.
Joins are automatically generated by DomainObjects when you specify a path in your Criteria.
For example, see the following unit test:
/// <summary>
/// Tests Criteria.AddEqualTo() with an inner join in the reference path
/// </summary>
[Test]
public void AddEqualToWithInnerJoin()
{
// Create a new instance of Criteria
Criteria criteria = new Criteria();
// Constrain the search to products where the product category name is 'Liquors'.
// Note that, because the '_productCategory' argument represents an object referenced
// by Product, DomainObjects will automatically generate SQL that contains
// an inner join between the PRODUCT table and the referenced PRODUCT_CATEGORY table.
criteria.AddEqualTo(Types.Product._productCategory.Field._name, "Liquors");
// Query the database, i.e., find the list of objects of type Product
// that match the given criteria.
List<Product> results = QueryFacade.FindObjectSet<Product>(criteria);
Assert.Greater(results.Count, 0, "Found some results.");
}
Hope this helps,
Richard
Great!
Thanks for the quick reply.
That was simple enough.
I have also looked at the outer joins test.
Thanks a lot.