/// <summary> /// Get a List of EwavColumns for the selected DataTable /// </summary> /// <param name="DatasourceName"></param> /// <param name="Tablename"></param> /// <returns></returns> public static List <EwavColumn> GetColumns(string DatasourceName, string Tablename) { //CommonSQLDAO commonDao = new CommonSQLDAO(); //// Get one row to get to to the columns //DataTable dt = commonDao.GetTableTopRow(DatasourceName, Tablename); EntityManager em = new EntityManager(); DataTable dt = em.GetTopTwoTable(DatasourceName, Tablename); List <EwavColumn> resultList = new List <EwavColumn>(); foreach (DataColumn dc in dt.Columns) { EwavColumn ewavColumn = new EwavColumn() { Index = resultList.Count, Name = dc.ColumnName, SqlDataTypeAsString = GetDBType(dc.DataType) }; // System.Data.SqlDbType resultList.Add(ewavColumn); } return(resultList); }
/// <summary> /// Get a List of EwavColumns for the selected DataTable /// </summary> /// <param name="DatasourceName"></param> /// <param name="Tablename"></param>k /// <returns></returns> public static List <EwavColumn> GetColumns(DataTable dt) { List <EwavColumn> resultList = new List <EwavColumn>(); foreach (DataColumn dc in dt.Columns) { EwavColumn ewavColumn = new EwavColumn() { Index = resultList.Count, Name = dc.ColumnName, SqlDataTypeAsString = GetDBType(dc.DataType) }; resultList.Add(ewavColumn); } return(resultList); }
/// <summary> /// Columnses as list. /// </summary> /// <returns></returns> public List <EwavColumn> GetColumnsForDatasource(string dataSourceName, string userName, DataTable dt) { // select the right one DataRow[] dr = dt.Select(string.Format("DatasourceName = '{0}' ", dataSourceName)); // convert type to enum DataBaseTypeEnum externalDataBaseType = (DataBaseTypeEnum)Enum.Parse(typeof(DataBaseTypeEnum), dr[0]["DataBaseType"].ToString()); string externalDataConnectionString = Ewav.DAL.Utilities.CreateConnectionString(externalDataBaseType, dr); // Get the right factory string externalDataViewName = dr[0]["DatabaseObject"].ToString(); DAL.Interfaces.IDaoFactory externalDaoFactory = DaoFatories.GetFactory(externalDataBaseType, externalDataConnectionString, externalDataViewName); // Get the columns DataTable dtColumns = externalDaoFactory.RawDataDao.GetColumnsForDatasource(dr); // create list of EwavColumn List <EwavColumn> ewavColumns = new List <EwavColumn>(); try { foreach (DataColumn col in dtColumns.Columns) { EwavColumn ec = new EwavColumn { Index = ewavColumns.Count, Name = col.ColumnName, SqlDataTypeAsString = Ewav.BAL.Common.GetDBType(col.DataType) }; ewavColumns.Add(ec); } } catch (Exception ex) { throw new Exception("Error with data columns == " + ex.Message + ex.StackTrace); } return(ewavColumns); }