I am looking for any examples or guides to using Linq over WCF (n-tier application). Please specify if you are showing something for Linq-to-SQL or Linq-to-entities. I would like to see usage examples for both.
I am wondering how things like deffered execution works over WCF (if it works at all)? Cyclic references support and so on...
Any information to make this a quick start guide to using Linq with WCF is helpful.
There isn't any LINQ provider that I'm aware of for generic WCF-based queries. LINQ to ADO.NET Data Services, however, lets you query an Entity model over WCF/REST.
From Andy Conrad's blog:
static void Main(string[] args)
{
var context=new WebDataContext("http://localhost:18752/Northwind.svc");
var query = from p in context.CreateQuery<Product>("Products")
where p.UnitsInStock > 100
select p;
foreach (Product p in query)
{
Console.WriteLine(p.ProductName+", UnitsInStock="+p.UnitsInStock);
}
}
You can add a Linq to SQL class to a WCF service. Then go to your datacontext in the Linq to SQL class and in the properties set Serialization Mode to Unidirectional.
The entities in your Linq to SQL class will now be available through the WCF service :)
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