有人可以解释为什么,当查询应该只返回一个字符串项时,如下例所示;
From c in context.Products Where c.Id=prodId Select c.Name
为什么不能这样做呢?
Dim prodDeleted as String = (From c in context.Products Where c.Id=prodId Select c.Name).ToString()
因为它返回 this (System.Data.Objects.ObjectQuery`1[System.String]) ,而不是产品名称
而不是必须这样做;
Dim prodDeleted = (From c In ctx.products
Where c.Id = prodId
Select c).FirstOrDefault()
Dim deletedprodname As String = prodDeleted.Name.ToString()