我有一张桌子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) 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',或者定义一次,并且每次使用特定值初始化.
我已将一个函数附加到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) 请参考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.如何总结各自的值SubObj从MainObj 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) 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# ×2
.net ×1
generics ×1
javascript ×1
lambda ×1
linq ×1
list ×1
null ×1
php ×1
sql ×1
sql-server ×1
t-sql ×1
woocommerce ×1
wordpress ×1