以下查询
SELECT
t.NAME AS TableName,
p.rows AS RowCounts,
SUM(a.total_pages) * 8 AS TotalSpaceKB,
SUM(a.used_pages) * 8 AS UsedSpaceKB,
(SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS UnusedSpaceKB
FROM
sys.tables t
INNER JOIN
sys.indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN
sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN
sys.allocation_units a ON p.partition_id = a.container_id
WHERE
t.NAME NOT LIKE 'dt%'
AND t.is_ms_shipped = 0
AND i.OBJECT_ID > 255
GROUP BY
t.Name, p.Rows
ORDER BY
t.Name
返回一个我希望在实体框架的UI上显示的表。正如您所看到的,无法创建表,因为它是动态的。
可以使用Entity Framework
完成吗?
答案 0 :(得分:0)
使用Context.Database.SqlQuery(yoursql)并使用泛型重载并提供自定义类型。 EF将使用选定的列值填充模型,因此为模型属性提供与列相同的名称(例如TableName,RowCounts)