Salakhetdinov Shamil
mcp2004 at mail.ru
Fri May 4 04:18:29 CDT 2012
Hi All --
Even more dynamic oData web service test call:
using System;
using System.Linq;
using System.Data.Services.Client;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
var proxy = (new DataServiceContext(new Uri(@"http://services.odata.org/Northwind/Northwind.svc/")).CreateQuery<dynamic>("Employees"));
var employees = from e in (proxy.ToList())
where e.Title.StartsWith("Sales")
orderby e.LastName
select e;
employees.ToList().ForEach(e =>
Console.WriteLine("{0}. {1} {2} - {3}", e.EmployeeID, e.LastName, e.FirstName, e.Title));
}
}
}
Just musing around mainstream tendency outlined here:
http://www.hanselman.com/blog/BackToBasicsMovingBeyondForIfAndSwitch.aspx
Thank you.
-- Shamil
Thu, 03 May 2012 22:51:25 +0400 от Salakhetdinov Shamil <mcp2004 at mail.ru>:
> Hi All --
>
> BTW, here is a fully dynamic (/"extra" late bound) sample oData web service client call - for the ones who likes such a level of risk/dynamism :)
>
> using System;
> using System.Linq;
> using System.Data.Services.Client;
>
> namespace ConsoleApplication1
> {
> public class DataModelProxy : DataServiceContext
> {
> public DataModelProxy(Uri serviceRoot) : base(serviceRoot) {}
>
> public IQueryable<dynamic> EmployeesList
> {
> get { return CreateQuery<dynamic>("Employees"); }
> }
>
> //public IQueryable<TestService.Employee> StronglyTypedEmployeesList
> //{
> // get { return CreateQuery<TestService.Employee>("Employees"); }
> //}
> }
>
> class Program
> {
> static void Main(string[] args)
> {
> var proxy = new DataModelProxy(new Uri(@"http://services.odata.org/Northwind/Northwind.svc/"));
>
> //var employees = from e in proxy.StronglyTypedEmployeesList where e.Title.StartsWith("Sales") orderby e.LastName select e;
>
> var employees = from e in ((proxy.EmployeesList).ToList())
> where e.Title.StartsWith("Sales")
> orderby e.LastName
> select e;
>
> foreach (var e in employees)
> {
> Console.WriteLine("{0}. {1} {2} - {3}", e.EmployeeID, e.LastName, e.FirstName, e.Title);
> }
> }
> }
> }
>
> Thank you
>
> -- Shamil
>
<<< snip >>>