小编Geo*_*bes的帖子

在表格中选择人员并排除妻子,但要结合他们的名字

我有一张桌子Person:

PersonID | FirstName | LastName
-------------------------------
1        |   John    |  Doe
2        |   Jane    |  Doe
3        |  NoSpouse | Morales
4        | Jonathan  | Brand
5        | Shiela    | Wife
Run Code Online (Sandbox Code Playgroud)

还有一张Relationship桌子:

RelationshipID | PersonID | Type | RelatedPersonID
1              |    1     |  3   |     2
2              |    2     |  3   |     1
3              |    4     |  3   |     5
4              |    5     |  3   |     4
Run Code Online (Sandbox Code Playgroud)

所以基本上,我想结合配偶和客户的名字,但我想排除配偶:

预期成绩:

1,  John and Jane Doe, 2 …
Run Code Online (Sandbox Code Playgroud)

sql t-sql sql-server

14
推荐指数
1
解决办法
797
查看次数

迭代期间变量的范围/寿命

for (index1 = 1; index1 < 8; index1++) {
  var op = '#';
  for (index2 = index1; index2 - 1; index2--) {
    op = op + '#';

  }
  console.log(op);
}
Run Code Online (Sandbox Code Playgroud)

在上面的代码和语句"var op ='#';"中,每次在'for'迭代中定义和初始化变量'op',或者定义一次,并且每次使用特定值初始化.

javascript

3
推荐指数
1
解决办法
69
查看次数

woocommerce_checkout_order_processed 钩子执行函数两次

我已将一个函数附加到woocommerce_checkout_order_processed钩子上:

//check if woocommerce is acive
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
    add_action('woocommerce_checkout_order_processed', 'wc_on_place_order');
}
Run Code Online (Sandbox Code Playgroud)

wc_on_place_order函数将在用户单击按钮后执行PLACE ORDER。然而,奇怪的是该函数执行了两次。

我的wc_on_place_order函数调用用 C# 编写的外部 api:

function wc_on_place_order( $order_id ) {
    global $wpdb;

    // get order object and order details
    $order = new WC_Order( $order_id ); 
    
    // get product details
    $items = $order->get_items();
    //return $items;
    
    $products = array();
    foreach ($items as $item) {
        array_push($products, 
            array('userid' => $order->user_id, 'descr' => $item['name'], 'amt' => (float)$item['line_total'])
        );
    }

    //passing $products to …
Run Code Online (Sandbox Code Playgroud)

php wordpress woocommerce hook-woocommerce

2
推荐指数
1
解决办法
2万
查看次数

Sum List <T> List <T>中每个项目的属性

请参考ff.代码:

MainObj:

public class MainObj {
    public string Name { get; set; }
    public int SomeProperty { get; set; }
    public List<SubObj> Subojects { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

SubObj:

public class SubObj {
    public string Description { get; set; }
    public decimal Value { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

问题:我有一个List<MainObj>.每个项目的数量相同SubObj.如何总结各自的值SubObjMainObj A对应于同一指数作为SubObj在其他MainObj列表中.

进一步说明:

结果:

{
    Name: "something....",
    Value: SUM(MainObj_A.SubObj[0], MainObj_B.SubObj[0] .... MainObj_n.SubObj[0]
},
{
    Name: "don't really care...."
    Value: …
Run Code Online (Sandbox Code Playgroud)

.net c# linq lambda list

1
推荐指数
1
解决办法
111
查看次数

Nullable types in generic class

I need to create a class similar to this:

class GenericClass<T>
{
    public T[] Arr {get; }
    public GenericClass(int n)
    {
        Arr = new T[n];
        for (int i = 0; i < n; i++)
        {
            Arr[i] = null;
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

But there is a compiler error:

CS0403 Cannot convert null to type parameter 'T' because it could be a non-nullable value type. Consider using 'default(T)' instead.

I don't want to use default(T), because it could be the same …

c# generics null

1
推荐指数
3
解决办法
7576
查看次数