2 Replies - 2232 Views - Last Post: 05 October 2010 - 09:20 AM Rate Topic: -----

#1 Guest_solo*


Reputation:

LINQ C#VS2010

Posted 04 October 2010 - 06:54 PM

if we have 3 records with employeeID,name and dateofbirth coloumns..and we have to show two coloumns out of these three coloumns ..then how can you show in c# code using LINQ code in it ?
Is This A Good Question/Topic? 0

Replies To: LINQ C#VS2010

#2 eclipsed4utoo  Icon User is offline

  • Not Your Ordinary Programmer
  • member icon

Reputation: 1526
  • View blog
  • Posts: 5,961
  • Joined: 21-March 08

Re: LINQ C#VS2010

Posted 04 October 2010 - 09:19 PM

var employees = from c in myDataContext.Employees
                select new Employee
                {
                    Name = c.Name,
                    DateOfBirth = c.DateOfBirth
                };



myDataContext is the name of your Data Context class. Employees will need to match the actual name of your table. Use IntelliSense for this.

Personally, I would get all three columns. You will probably need the EmployeeID later on.
Was This Post Helpful? 2
  • +
  • -

#3 Curtis Rutland  Icon User is offline

  • (╯□)╯︵ (~ .o.)~
  • member icon


Reputation: 4559
  • View blog
  • Posts: 7,980
  • Joined: 08-June 10

Re: LINQ C#VS2010

Posted 05 October 2010 - 09:20 AM

Quote

Personally, I would get all three columns. You will probably need the EmployeeID later on.


Agreed. There's no reason to lose data for display purposes. You just don't have to bind a UI component to that specific field.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1