comparison Demo/Linq/OverWCF/Program.cs @ 0:f990fcb411a9

Копия текущей версии из github
author cin
date Thu, 27 Mar 2014 21:46:09 +0400
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:f990fcb411a9
1 using System;
2 using System.Linq;
3 using System.ServiceModel;
4 using System.ServiceModel.Description;
5
6 using BLToolkit.Data;
7 using BLToolkit.ServiceModel;
8
9 namespace Linq.OverWCF
10 {
11 class Program
12 {
13 static void Main()
14 {
15 DbManager.TurnTraceSwitchOn();
16
17 using (var host = new ServiceHost(new LinqService("Sql2008"), new Uri("net.tcp://localhost:1234")))
18 {
19 host.Description.Behaviors.Add(new ServiceMetadataBehavior());
20 host.Description.Behaviors.Find<ServiceDebugBehavior>().IncludeExceptionDetailInFaults = true;
21 host.AddServiceEndpoint(typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexTcpBinding(), "mex");
22 host.AddServiceEndpoint(
23 typeof(ILinqService),
24 new NetTcpBinding(SecurityMode.None)
25 {
26 MaxReceivedMessageSize = 10000000,
27 MaxBufferPoolSize = 10000000,
28 MaxBufferSize = 10000000,
29 CloseTimeout = new TimeSpan(00, 01, 00),
30 OpenTimeout = new TimeSpan(00, 01, 00),
31 ReceiveTimeout = new TimeSpan(00, 10, 00),
32 SendTimeout = new TimeSpan(00, 10, 00),
33 },
34 "LinqOverWCF");
35
36 host.Open();
37
38 var client = new DataModel();
39
40 var q =
41 from p in client.Person
42 select new
43 {
44 p.PersonID,
45 p.FirstName,
46 p.MiddleName,
47 p.LastName,
48 p.Gender
49 };
50
51 foreach (var p in q)
52 Console.WriteLine(p);
53
54 Console.ReadLine();
55
56 host.Close();
57 }
58 }
59 }
60 }