嵌套查询不适用于Entity Framework绑定转发器控件

时间:2019-01-22 16:23:33

标签: c# sql linq entity-framework-6

string sql = string.Format(
    @"SELECT M.ManufacturerID
            ,M.DeviceCode
            ,M.DeviceName
            ,M.Repertoire,
        (SELECT COUNT(*) FROM Catalogue AS [C] WHERE(([C].ManufacturerID = [M].ManufacturerID) AND ([C].DeviceCode = [M].DeviceCode) AND ([C].VendorID = [V].VendorID)))  [LotsCount]
            FROM Manufacturers AS [M]
            LEFT JOIN Vendors AS [V] ON [V].ManufacturerID = M.ManufacturerID
            WHERE (([V].VendorID LIKE ‘%V0%’)  AND ([M].Enabled = 1))
            ORDER BY [M].DeviceCode")

return  ctx.Manufacturers.SqlQuery(sql).ToList();

返回值将绑定转发器控件,但此处[LotsCount]未绑定到我的转发器

<itemtemplate> 

<asp:HyperLink ID="LST_LotsCount" Text='<%# Eval("LotsCount") %>' runat="server"></asp:HyperLink>

0 个答案:

没有答案