MySqlConnection connection = new MySqlConnection("datasource=;port=;username=;password="); connection.Open(); string sQuery = "select * from DB.table1 WHERE date = '" + d1 + "' and date <='" + d2+ "' "; MySqlDataAdapter cmd= new MySqlDataAdapter(sQuery, connection); DataSet ds = new DataSet(); cmd.Fill(ds); //Conversion part code Excel.Application app; Excel.Workbook wb; Excel.Worksheet ws; object misValue = System.Reflection.Missing.Value; app = new Excel.Application(); app.Visible = true; wb = app.Workbooks.Add(misValue); ws = (Excel.Worksheet)wb.ActiveSheet; for (int i = 0; i < ds.Tables[0].Columns.Count; i++) { ws.Cells[1, i + 1] = ds.Tables[0].Columns[i].ColumnName; } for (int k = 1; k < ds.Tables[0].Rows.Count; k++) { for (int j = 0; j < ds.Tables[0].Columns.Count; j++) { ws.Cells[k + 1, j + 1] = ds.Tables[0].Rows[k][j].ToString(); } }
table_Entity result = new table_Entity(); var EntityQuery=from t in DB.Table1 where t.date >= d1 && t.date <= d2 select t; var result = EntityQuery.ToList();
string sQuery = "select * from DB.table1 WHERE date = '" + d1 + "' and date <='" + d2+ "' ";
INSERT
Quote:My question is to do the same operation using entity framework model query .
table_Entity result = new table_Entity(); var EntityQuery=from t in DB.Table1 where t.date >= d1 && t.date <= d2 select t;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)