Jump to content



Photo
c# linq

  • Please log in to reply
No replies to this topic

#1 Kalint

Kalint

    Neowinian Senior

  • Tech Issues Solved: 2
  • Joined: 16-January 07

Posted 26 November 2012 - 19:41

Partial Form Code

        // Form Load
        private void FrmBuildersManageLoad(object sender, EventArgs e)
        {
            // Controller
            LstBuilders.MultiSelect = false;
            LstBuilders.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
            LstBuilders.DataSource = Accessor.DisplayBuilders();
            LstBuilders.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.DisplayedCells);
        }



Partial Accessor Code

    // BUILDERS RESULTS
    public class BuildersResults
    {
        public string Builder { get; set; }
        public string Address { get; set; }
        public string City { get; set; }
        public string State { get; set; }
        public string Zip { get; set; }
        public string PhoneNumber { get; set; }
        public string FaxNumber { get; set; }
        public string EmailAddress { get; set; }
    }


        // Get Full Table of Builders
        public static List<BuildersResults> DisplayBuilders()
        {
            var dataConnect = new PxLinqSqlDataContext();

            return (from b in dataConnect.GetTable<TblBuilders>()
                    select new BuildersResults
                               {
                        Builder = b.Contact,
                        Address = b.Address,
                        City = b.City,
                        EmailAddress = b.EmailAddress,
                        FaxNumber = b.FaxNumber,
                        PhoneNumber = b.PhoneNumber,
                        State = b.State,
                        Zip = b.Zip               
                    }).ToList();
        }





Click here to login or here to register to remove this ad, it's free!