Пример #1
0
        /// <summary>
        /// Etablishes a connection to the WCF Service.
        /// </summary>
        /// <returns>Returns the etablished connection.</returns>
        private IQueryRemoteHandler Connect()
        {
            ClientQueryWcfHandler clientHandler = new ClientQueryWcfHandler();

            var binding  = ServiceHelper.GetDefaultBinding();
            var endpoint = ServiceHelper.GetEndpoint(remoteAddress, null, serviceName);

            clientHandler.Connect(binding, endpoint);
            return(clientHandler.QueryRemoteHandler);
        }
Пример #2
0
        /// <summary>
        /// Etablishes a connection to the WCF Service.
        /// </summary>
        /// <returns>Returns the etablished connection.</returns>
        private IQueryRemoteHandler Connect()
        {
            ClientQueryWcfHandler clientHandler = new ClientQueryWcfHandler();

            NetTcpBinding   netTcpBinding = ServiceHelper.GetNetTcpBinding();
            EndpointAddress endpoint      = ServiceHelper.GetEndpoint(null, null, serviceName);

            clientHandler.Connect(netTcpBinding, endpoint);
            return(clientHandler.QueryRemoteHandler);
        }
Пример #3
0
        /// <summary>
        /// The main method.
        /// </summary>
        static void Main()
        {
            Console.WriteLine("InterLinq.Examples.Simple.Client is going to start...");

            // Connect to the server
            // using the default connection (TCP-Binding, Binary, tcp://localhost:7890/InterLinqService)
            Console.WriteLine("Connecting to the server...");
            ClientQueryWcfHandler clientQueryHandler = new ClientQueryWcfHandler();

            clientQueryHandler.Connect("InterLinqServiceNetTcp");

            // Create a SimpleExampleContext
            Console.WriteLine("Creating a SimpleExampleContext...");
            SimpleExampleContext simpleExampleContext = new SimpleExampleContext(clientQueryHandler);

            Console.WriteLine("Client is connected.");
            Console.WriteLine();

            #region Execute some LINQ statements
            Console.WriteLine("Execute some LINQ statements...");

            #region Query 1

            var selectAllSimpleObjects = from so in simpleExampleContext.SimpleObjects
                                         select so;
            Console.WriteLine("{0} SimpleObjects are stored on the server.", selectAllSimpleObjects.Count());

            #endregion

            #region Query 2

            var valueOver9 = from so in simpleExampleContext.SimpleObjects
                             where so.Value > 9
                             select so;
            Console.WriteLine("{0} SimpleObjects have a value over 9.", valueOver9.Count());

            #endregion

            #region Query 3

            SimpleObject lastObject = (from so in simpleExampleContext.SimpleObjects
                                       select so).Last();
            Console.WriteLine("The name of the last Object is '{0}' and the value '{1}'.", lastObject.Name, lastObject.Value);

            #endregion

            #endregion

            // Wait for user input
            Console.WriteLine();
            Console.WriteLine("Press [Enter] to quit.");
            Console.ReadLine();
        }