如何在DevExpress XAF中处理非持久数据?

时间:2014-06-28 02:34:17

标签: c# devexpress xaf

我需要创建一些查询,这些查询将用于在仪表板中创建图表。查询是很多计算,并且是非持久类。

首先我创建了这个类,但只有这个我有HPerformance_ListView和HPerformance_DetailView,但是我没有数据提供者来填充它。系统尝试从EF上下文填充它,这是不可能的。

[NavigationItem]
[NonPersistent]
public class HPerformance
{
    public decimal Valor { get; set; }
    public decimal Meta { get; set; }
    public decimal Percentual { get; set; }
}

查询类

public class MetasVendas
{
    public MetasVendas()
    {
        fromDate = DateTime.Now.AddMonths(-1);
        toDate = DateTime.Now;
        revenda = 0;
    }

    public DateTime fromDate { get; set; }
    public DateTime toDate { get; set; }
    public long revenda { get; set; }

    public BindingList<HPerformance> _hPerformance()
    {
        var r = _calculoMetaEValor();

        var rr = r.GroupBy(g => true).Select(s => new HPerformance()
        {
            Valor = s.Sum(v => v.TotalUSacess + v.TotalUSradio),
            Meta = s.Sum(v => v.Meta),
            Percentual = s.Sum(vv => vv.TotalUSacess + vv.TotalUSradio) / s.Sum(vv => vv.Meta)
        });

        return new BindingList<HPerformance>(rr.ToList());
    }

在仪表板控制器中,这是我不知道如何处理的代码。我的例子不起作用

public partial class DashboardDealerGoalExecute : ViewController<DashboardView>
{
    void parametersViewItem_ControlCreated(object sender, EventArgs e)
    {
        DashboardViewItem viewItem = (DashboardViewItem)sender;

        if (viewItem.Id == "HPerformance")
        {
            ListView _hPerformance = (ListView)viewItem.InnerView;

            if (parameters != null && parameters.Dealer != null)
            {
                BindingList<HPerformance> hp =
                    new MetasVendas()
                    {
                        fromDate = parameters.FromDate,
                        toDate = parameters.ToDate,
                        revenda = parameters.Dealer.ID
                    }._hPerformance();
                _hPerformance.CurrentObject = hp;
            }
        }

HPerformance是一个信息中心项目,已连接到HPerformance类(第一个代码)。如何设置HPerformance_ListView方法填充_hPerformance()

谢谢, 马可·卡斯特罗

0 个答案:

没有答案