Click here to Skip to main content
15,884,821 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello,

I am writing a small application. This contains only one table called master. This contains about 280 fields and i am using Linq to Entities to use.

Following is the code.

C#
List<Master> dataAcc = new List<Master>();
       public MainWindow()
       {
           InitializeComponent();
           dataAcc = Getmembers();
        }

       public List<Master> Getmembers()
       {
           BillingEntities billEntity = new BillingEntities(DataAccess.GetConnectionStringForSelectedPractice("MyDB"));

           List<Master> dataAccount = (from p in billEntity.DataAccounts
                                            where p.Duplicate == false
                                            select p
                                            ).Take(1000).ToList<Master>();

           return dataAccount;


       }



Actually i need only three columns out of 280 columns but Linq to Entities is not accepting to write code in the following way as like linq to sql.

C#
 List<master> dataAcc = new List<Master>();
        public MainWindow()
        {
            InitializeComponent();
            dataAcc = Getmembers();
         }

        public List<master> Getmembers()
        {
            BillingEntities billEntity = new BillingEntities(DataAccess.GetConnectionStringForSelectedPractice("MyDB"));

            List<master> dataAccount = (from p in billEntity.DataAccounts
                                             where p.Duplicate == false
                                             select new Master
{
  AcctNumber = p.AcctNumber,
  Name = p.Name,
  BirthDay = p. DOB
}
).Take(1000).ToList<master>();

return dataAccount;
}

Is it possible to acheive this????

chowdary.</master></master></master></dataaccount></dataaccount>
Posted
Updated 4-Oct-12 21:00pm
v3

1 solution

Hi,

I suggest you to create new "dataholder" class for that purpose, which will have only few properties (AcctNumber, Name and BirthDay in your case) of your Master class!
You can name it SimpleMatserDTO for example or similar and use it as return type in your method...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900