2

我有一个 LINQ to Entities 查询,它假设根据提供的 GUID 返回一个特定的结果集。

    [OperationContract, WebGet(ResponseFormat = WebMessageFormat.Json)]
    public List<OrderDetails> GetOrderDetailsByGUID(Guid OrderID)
    {
        var listit =(from OV in EC.OrderProductVariants
                join O in EC.Orders on OV.OrderId equals O.Id
                join PV in EC.ProductVariants on OV.ProductVariantId equals PV.Id
                join P in EC.Products on PV.ProductId equals P.Id
                join CT in EC.Customers on O.CustomerId equals CT.Id
                join AD in EC.Addresses on CT.BillingAddress_Id equals AD.Id
                where O.OrderGuid == OrderID
                select new OrderDetails
                {
                    OrderID = O.OrderGuid,
                    Company = AD.Company,
                    ShippingMethod = O.ShippingMethod,
                    Product = P.Name,
                    QuantityOnOrder = OV.Quantity
                }
                    ).ToList();

        return listit;
    }

它返回NULL,谁能告诉我我做错了什么?

4

1 回答 1

2

可以在这样的场景中工作的所有解决方案都是创建一个视图并只执行一行代码来访问它

var q = EC.OrderProductVariants.SingleOrDefault(u => u.OrderGuid.Equals(guid));
于 2013-08-01T12:33:50.857 回答