• 0

Why does this code run like hell? Populate DataGridView with LINQ


Question

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);
}
[/CODE]

Partial Accessor Code

[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();
}
[/CODE]

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.