case

How Order by Case in LINQ

て烟熏妆下的殇ゞ 提交于 2021-02-05 08:41:53
问题 I have this answer Entity framework OrderBy "CASE WHEN" but this only handle two options var p = ctx.People.OrderBy(p => (p.IsQualityNetwork == 1 || p.IsEmployee == 1) ? 0 : 1) .ThenBy(p => p.Name); I have a text field and want rows appear on an specific order. In sql I would do: ORDER BY CASE when name = "ca" then 1 when name = "po" then 2 when name = "pe" then 3 when name = "ps" then 4 when name = "st" then 5 when name = "mu" then 6 END 回答1: How about creating a map of your sort order? var

How Order by Case in LINQ

故事扮演 提交于 2021-02-05 08:41:29
问题 I have this answer Entity framework OrderBy "CASE WHEN" but this only handle two options var p = ctx.People.OrderBy(p => (p.IsQualityNetwork == 1 || p.IsEmployee == 1) ? 0 : 1) .ThenBy(p => p.Name); I have a text field and want rows appear on an specific order. In sql I would do: ORDER BY CASE when name = "ca" then 1 when name = "po" then 2 when name = "pe" then 3 when name = "ps" then 4 when name = "st" then 5 when name = "mu" then 6 END 回答1: How about creating a map of your sort order? var

SQL UPDATE and CASE statement does not work

情到浓时终转凉″ 提交于 2021-01-29 15:09:07
问题 I have the following table "Sales" in MS SQL Server, where [FieldX] is not updated properly: (..[My comment] is of course not an actual column in the table) The reason why the last 3 rows should be = 3, is because I am updating the fields with the following rules: with cte_previous_rows AS ( SELECT Staff_Id, LAG(FieldX) OVER (partition by Staff_Id ORDER by [date]) as Prev_Row FROM Sales ) UPDATE Sales SET FieldX = (CASE WHEN Staff_id_sales < 1500 AND ClosedSale = 0 THEN 0 WHEN Staff_id_sales

mysql window function with case

三世轮回 提交于 2021-01-28 11:36:45
问题 I'm trying to perform a window function with a built in case. Here's an example which should make it more clear. Original Table: SELECT trade_date, ticker, trans_type, quantity FROM orders WHERE trade_date >= '2020-11-16'; Results: |trade_date|ticker|trans_type|quantity| |:---------|:-----|:---------|-------:| |2020-12-10|FB |BUY |100 | |2020-12-28|FB |BUY |50 | |2020-12-29|FB |SELL |80 | |2020-12-30|FB |SELL |30 | |2020-12-31|FB |BUY |40 | |2020-11-16|AAPL |BUY |30 | |2020-11-17|AAPL |SELL

crosses initialization error in switch case statement

泪湿孤枕 提交于 2021-01-28 07:02:21
问题 I've got the following code: Class A { public: A::A(const char* name): _name(name) {} virtual void doSomething(); private: const char* _name; } Class B : public A { B::B(const char* name): A(name) {} void doSomething() { //do something } } So far so good, but I've experiencing an error crosses initialization of B* newB in the following code: std::vector<A*> vectorOfAs; switch (enumType) { case enum1 : B* newB = new B("foobar"); vectorOfAs.push_back(newB); break; case enum2 : C* newC = new C(

BASH Not In Case

夙愿已清 提交于 2020-12-26 06:39:39
问题 I am trying to figure out a sane way to do a NOT clause in a case. The reason I am doing this is for transcoding when a case is met, aka if I hit an avi, there's no reason to turn it into an avi again, I can just move it out of the way (which is what the range at the base of my case should do). Anyway, I have some proto code that I wrote out that kind of gives the gist of what I am trying to do. #!/bin/bash for i in $(seq 1 3); do echo "trying: $i" case $i in ! 1) echo "1" ;; # echo 1 if we