views:

19

answers:

0

I have a entity Person. at server side, take EF as DAL. then I extend this entity by adding a read only member:

[DataMember]
public decimal AccountBalance
{
  get
  {
      using (MyEntities ctx = new MyEntities())
      {       
        return 123.45M;
      }
   }
}

Client side get the date by ria service by

 public IQueryable<Person> GetPerson()
   {
  try
  {
    var person = this.Context.Person();
    return person;
  }
  catch (Exception ex)
  {
    return null;
  }
}

It works fine. But if I try to get the read only member data by Linq like:

[DataMember]
public decimal AccountBalance
{
  get
  {
      using (MyEntities ctx = new MyEntities())
      {
         var ba = ctx.Transactions.Where(e => e.ID == this.ID).Sum(t => t.Amount);
         return (decimal)ba;
      }     
  }
}

I get nothing at client side. when debug the app, var ba has correct data, but at client side, Call GetPerson will give me 0 count for the entity collection.

Very confused. How to resolve it?