public class CustomerInfo
{
public string CusID { get; set; }
public string CusName { get; set; }
public string CountryName { get; set; }
}
private void frmMain_Load(object sender, EventArgs e)
{
// Create new entities from Entities
using (var db = new myDatabaseEntities())
{
// Select
string strSQL = string.Empty;
strSQL = "SELECT A.CUSTOMER_ID AS CusID,A.NAME AS CusName, B.COUNTRY_NAME AS CountryName ";
strSQL += "FROM CUSTOMER A ";
strSQL += "LEFT JOIN COUNTRY B ON A.COUNTRY_CODE = B.COUNTRY_CODE";
var ds = db.Database.SqlQuery<CustomerInfo>(strSQL).ToList();
// if found item rows
if (ds.Count() > 0)
{
this.myDataGridView.DataSource = ds;
}
}
}