Wednesday, July 8, 2009

RemoteTable and DALinq

In my last blog post on DALinq I was trying to figure out how I could have my query be more natural looking. The GetTable method simply looked out of place. I've gotten used to it, but think I see how to get around it now after looking at how LINQ to SQL works. The linqRemoteDataAdapter.GetTable<T>() method returns the type RemoteTable<T>. Simply assign it to a variable and use that variable from then on if you like:


RemoteTable<Customers> OurCustomers = linqRemoteDataAdapter.GetTable<Customers>();

var aList = from cust in OurCustomers
where (cust.City == "México D.F.")
orderby cust.ContactName ascending
select new { cust.CustomerID, cust.ContactName, cust.Address, cust.City };


Or if you prefer dot notation:


RemoteTable<Customers> OurCustomers = linqRemoteDataAdapter.GetTable<Customers>();

var aList = OurCustomers
.Where(cust => cust.City == "México D.F.")
.OrderBy(cust => cust.ContactName)
.Select(cust =>
new { cust.CustomerID, cust.ContactName, cust.Address, cust.City });


So if you're using DALinq in RemObjects DataAbstract for your n-tier framework you can use either the GetTable syntax or create a variable and do it more like the books present examples with LINQ to Objects.


About The Author

Ron Grove draws on over ten years of training, network administration and development experience. He loves to work with new technology and see how that technology can be best utilized by his clients. You can find him through his company Evanoah, LLC and his LinkedIn profile is here.

0 comments:

Post a Comment