Exemplo n.º 1
0
        public object Clone()
        {
            SCMetaData md = new SCMetaData();

            if (m_fieldsList.Count > 0)
            {
                md.Fields.AddRange(m_fieldsList);
            }
            return(md);
        }
Exemplo n.º 2
0
        public static SCDataTable GetData(this DataTable dt)
        {
            SCDataTable dsd = new SCDataTable();

            if (string.IsNullOrWhiteSpace(dt.TableName))
            {
                throw new InvalidCastException("无效的表明");
            }
            dsd.TableName = dt.TableName;
            SCMetaData md = new SCMetaData();

            //提取元数据信息
            foreach (DataColumn col in dt.Columns)
            {
                SCField f = new SCField();
                f.Caption    = col.Caption;
                f.DataType   = col.DataType.ToString();
                f.Expression = col.Expression;
                f.FiledName  = col.ColumnName;
                f.IsKey      = col.Unique;
                f.IsReadOnly = col.ReadOnly;
                f.IsRequire  = !col.AllowDBNull;
                f.MaxLength  = col.MaxLength;
                md.AddField(f);
            }
            dsd.MetaData = md;
            //装数据
            List <List <object> > datas = new List <List <object> >();

            for (int i = 0; i < dt.Rows.Count; i++)
            {
                List <object> rowData = new List <object>();
                for (int j = 0; j < dt.Columns.Count; j++)
                {
                    rowData.Add(dt.Rows[i][j]);
                }
                datas.Add(rowData);
            }
            dsd.Datas = datas;
            return(dsd);
        }