terça-feira, 17 de setembro de 2013

Retrieving data using LINQ, creating and populating object at the same time

 Hi!

I found this way of create and populate object and, at the same time, retrieve data using LINQ.


        public CustomerModel find(string id)
        {
            DataClasses1DataContext lObjDC = new DataClasses1DataContext();

            var varCustomerModel = lObjDC.Customers.Where(x => x.CustomerID == id).Select(p => new CustomerModel(p.CustomerID, p.CompanyName)).Single();

            return varCustomerModel;
        }

Nenhum comentário:

Postar um comentário