小编d_r*_*_23的帖子

使用PHP创建JSON对象

如何使用PHP实现或创建此类型的JSON对象?

{ 
    "label": "Devices per year",
    "data": [
        [1999, 3.0], [2000, 3.9], [2001, 2.0], [2002, 1.2], [2003, 1.3], [2004, 2.5], [2005, 2.0], [2006, 3.1], [2007, 2.9], [2008, 0.9]
    ]
}
Run Code Online (Sandbox Code Playgroud)

几次尝试后,我没有找到解决方案.例如我试过这个:

$arrayDateAndMachine = array(
    "1999"=>3.0, 
    "2000"=>3.9
);   

$arr = array(
    "label" => "Devices per year", 
    "data" => $arrayDateAndMachine
);

var_dump(json_encode($arr));
Run Code Online (Sandbox Code Playgroud)

php json

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

带有多个 where 子句的 Entity Framework Core LINQ 查询

我的项目需要一些示例代码。我正在使用 EF CORE 2.1.1。

我创建了一个接受 3 个参数的函数,在该函数中我正在执行 LINQ(lambda 表达式查询),返回一个列表。

这是我的功能:

public IEnumerable<Donneesource> GetAllSourcesFromBDD(DateTime PremierDateCom, DateTime DerniereDateCom, string Secteur)
{
    try
    {
        //Récupération des données.
             IEnumerable<Donneesource> RawDatas = _sourceDAL.Donneesource
                .Where(ic => ic.EstCopieDestination == false)
                .Where(s => PremierDateCom != DateTime.MinValue && s.SComPremierDate.Value.Date == PremierDateCom.Date)
                .Where(s => DerniereDateCom != DateTime.MinValue && s.SComDerniereDate.Value.Date == DerniereDateCom.Date)                    
                .Where(s => Secteur != string.Empty && s.SSectNom == Secteur)
                .ToList();

        return RawDatas;              
    }
    catch(Exception)
    { 
        return null;
    }
}
Run Code Online (Sandbox Code Playgroud)

默认情况下,我将 DateTime 参数设置为 DateTime.MinValue (PremierDateCom,DerniereDateCom),将字符串参数设置为 string.Empty (Secteur)。

我正在尝试使用 where 子句创建 …

c# linq entity-framework-core

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

标签 统计

c# ×1

entity-framework-core ×1

json ×1

linq ×1

php ×1