Exemple #1
0
        //private System.Data.Services.Client.DataServiceQuery<AdventureWorksService.SalesOrderHeader> salesQuery;
        //private CollectionViewSource ordersViewSource;

        public ViewModel()
        {
            Enrollments = new List <Course>();
            BasicHttpBinding basicHttpbinding = new BasicHttpBinding(BasicHttpSecurityMode.None);

            basicHttpbinding.Name = "BasicHttpBinding_ICourse";
            basicHttpbinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.None;
            basicHttpbinding.Security.Message.ClientCredentialType   = BasicHttpMessageCredentialType.UserName;

            EndpointAddress endpointAddress = new EndpointAddress("http://localhost:59178/CourseService.svc");

            ServiceReference1.CourseClient courseClient = new ServiceReference1.CourseClient(basicHttpbinding, endpointAddress);
            var Data = courseClient.GetCourse();

            foreach (var item in Data.ToList())
            {
                Enrollments.Add(new Course()
                {
                    CourseId = item.CourseId, ClassSize = item.ClassSize, EndDate = item.EndDate, InstructorId = item.InstructorId, Name = item.Name, NickName = item.NickName, StartDate = item.StartDate, Title = item.Title
                });
            }
        }