0

I try to get DomainCollectionView, but Total Count doesn't include in query:

    public DomainCollectionView<sys_log> collView
    {
        get { return (DomainCollectionView<sys_log>)this.GetValue(collViewProperty); }
        set
        {
            this.SetValue(collViewProperty, value);
        }
    }

    public static DependencyProperty collViewProperty = DependencyProperty.Register(
      "collView", typeof(DomainCollectionView<sys_log>), typeof(Journal), new PropertyMetadata(null));

    this._source = this.maindatacontext.sys_logs;
    this._loader = new DomainCollectionViewLoader<sys_log>(this.LoadEntities, this.mdcloaded);
    this._view = new DomainCollectionView<sys_log>(this._loader, this._source);

    private LoadOperation<sys_log> LoadEntities()
    {
        EntityQuery<sys_log> temp = mdc.GetSys_logQuery().OrderBy(order => order.Id).Where(c => c.date > DateFrom.SelectedDate.Value && c.date < DateTo.SelectedDate.Value.AddDays(1).AddTicks(-1)).SortAndPageBy(this._view);
        temp.IncludeTotalCount = true;
        return mdc.Load(temp);
    }


    void mdcloaded(LoadOperation<Web.sys_log> t)
    {
            this.collView = _view;
            //but this _view.TotalItemCount = -1
            dataGrid1.UpdateLayout();
    }

dataGrid1 has ItemSource = collView. How I can set TotalItemCount or include it in query?

4

2 に答える 2

2

クエリのエンティティの総数を取得するには、DomainServiceのCountメソッドをオーバーライドする必要があります。

public class MyDomainService : DomainService{
   protected override int Count<T>(IQueryable<T> query) {
        return query.Count();
   }   
}
于 2012-09-11T07:46:36.167 に答える
0

クエリ関連のmdcのIncludeTotalCountを設定しているため、機能しないと思います。

しかし、DomainCollectionView < T > と入力された依存関係プロパティを調べます。

DomainCollectionView はあなたから実装されていますか? Silverlight は ICollectionView を提供するだけです。DomainCollectionView を実装した場合は、それを調べます。または、collView の Count プロパティを使用してみてください。ICollectionView の実装に関連している可能性があります。

           var qe=dSrvGD.GetGD_COUNTRYQuery();
            qe.IncludeTotalCount = true;
            dSrvGD.Load(qe).Completed += (s, e) =>
                {
                    if ((s as LoadOperation).TotalEntityCount<=0)
                    { 
                        //ASK WHY empty :)
                    }
                }
                ;

上記で使用した TotalEntityCount の説明はこちら、

    //
    // Summary:
    //     Gets the total server entity count for the query used by this operation.
    //     Automatic evaluation of the total server entity count requires the property
    //     System.ServiceModel.DomainServices.Client.EntityQuery.IncludeTotalCount on
    //     the query for the load operation to be set to true.

WCF が TotalCount -1 を返す前に同様の質問をし ましたが、エンティティがあります。

希望が役立ちます

于 2012-09-11T07:47:34.020 に答える