LINQ case语句

扫码查看
本文介绍了LINQ case语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助与LINQ CASE语句(C#):

  osc_products.products_quantity =
      案件
         WHEN itempromoflag<> 'N'THEN 100000
         WHEN itemcat1 IN('1','2','31')与itemsalestatus =STHEN 100000
         WHEN itemsalestatus ='O',那么0
         ELSE cds_oeinvitem.itemqtyonhand - cds_oeinvitem.itemqtycommitted
      结束

我在转换为LINQ的开始,(我还在学习):

This query updates stock status from production to a commerce site.

Thanks !!!

解决方案

If its just the CASE statement in LINQ your after (read your comment) then an example of this is...

Int32[] numbers = new Int32[] { 1, 2, 1, 3, 1, 5, 3, 1 };

var numberText =
(
    from n in numbers
    where n > 0
    select new
    {
        Number = n,
        Text =
        (
            n == 1 ? "One" :
            n == 2 ? "Two" :
            n == 3 ? "Three" : "Unknown"
        )
    }
);

Hope that helps :)

这篇关于LINQ case语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-28 01:38
查看更多