views:

372

answers:

1

We are trying to create a cool API using WCF and ICriteria, for example:

[ServiceContract]
public class ProductService
{
[OperationContract]
public List<Product> Get()

[OperationContract]
public List<Product> GetByCriteria(Criteria criteria)

}

We are thinking of using the DetachedCriteria so anyone can send it and we connect this to the Session in the Service for running the Query infront of our DB.

Is there anyone who create such API? Should we use the ICriteria from Nhibernate? Any other cool Ideas?

Thanks.

+2  A: 

This is not cool API. It's object oriented, not service oriented. And it will not work.

You will have to use KnownTypeAttribute (or ServiceKnownTypeAttribute) for polymorphic queries. (see this question).

Also this is not very elegant solution and I would discourage you from that. Be explicit when in Service World.

Krzysztof Koźmic
Can you send me a better example?
rabashani
Don't be too generic, and don't clutter your WCF services with other infrastructure framework code. Make your service specific and explicit. GetProductsByColor, or GetProductsByTypeAndPriceRange are good examples.
Krzysztof Koźmic