/// <summary> /// 查询表字段信息 /// </summary> /// <param name="tableId"></param> /// <returns></returns> public async Task <IEnumerable <TableFieldInfo> > GetFieldInfosAsync(int tableId) { string sql = @"SELECT FieldName = a.name, IsIdentity = case when COLUMNPROPERTY(a.id, a.name,'IsIdentity')= 1 then '√'else '' end, FieldType = b.name, OccupiedByte = a.length, TypeLength = COLUMNPROPERTY(a.id, a.name, 'PRECISION'), NumericScale = isnull(COLUMNPROPERTY(a.id, a.name, 'Scale'), 0), 'IsNullable' = case when a.isnullable = 1 then '√'else '' end, DefaultValue = isnull(e.text, ''), ColumnDescription = isnull(g.[value], '') FROM syscolumns a left join systypes b on a.xusertype = b.xusertype left join syscomments e on a.cdefault = e.id left join sys.extended_properties g on a.id = g.major_id and a.colid = g.minor_id where a.id = @tableid order by a.id,a.colorder"; return(await _dapperDbContext.QueryAsync <TableFieldInfo>(sql, new { tableid = tableId })); }
public async Task <IEnumerable <Product> > GetAllAsync() { return(await _context.QueryAsync <Product>()); }