Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net 如何将此Linq查询转换为Lambda表达式_Asp.net_Linq - Fatal编程技术网

Asp.net 如何将此Linq查询转换为Lambda表达式

Asp.net 如何将此Linq查询转换为Lambda表达式,asp.net,linq,Asp.net,Linq,可能是这样的: foreach (lc_ShoppingCart sc in shQuery) { //Decrement the Product Table's Total Remaining row with the quantity var ProductInventoryQuery = (from pr in db.lc_ProductInventories

可能是这样的:

        foreach (lc_ShoppingCart sc in shQuery)
        {
            //Decrement the Product Table's Total Remaining row with the quantity
            var ProductInventoryQuery = (from pr in db.lc_ProductInventories
                                         join c in db.lc_ColorTables on pr.Color equals c.Color
                                         join s in db.lc_SizeTables on pr.Size equals s.Size
                                         where pr.ProductID == Convert.ToInt32(sc.ProductID)
                                         where pr.Color == c.Color
                                         where pr.Size == s.Size
                                         select pr).First();
            ProductInventoryQuery.Quantity = ProductInventoryQuery.Quantity - sc.Quantity;
        }

可能是这样的:

        foreach (lc_ShoppingCart sc in shQuery)
        {
            //Decrement the Product Table's Total Remaining row with the quantity
            var ProductInventoryQuery = (from pr in db.lc_ProductInventories
                                         join c in db.lc_ColorTables on pr.Color equals c.Color
                                         join s in db.lc_SizeTables on pr.Size equals s.Size
                                         where pr.ProductID == Convert.ToInt32(sc.ProductID)
                                         where pr.Color == c.Color
                                         where pr.Size == s.Size
                                         select pr).First();
            ProductInventoryQuery.Quantity = ProductInventoryQuery.Quantity - sc.Quantity;
        }
使用LinqPad使用LinqPad