Can not load load from custom method of domain service class RRS feed

  • Question

  • Hi All,

    Need help for following query


    public class M_States_DomainService : LinqToEntitiesDomainService<GISMEDEntities1>


    public IQueryable<State> GetStateByStateCode(string stateCode)


    var query = from p in this.Context.EGT_M_State

    where p.id.Equals(stateCode)select new State()


    stateValue = p.description


    return query;



    public class State


    Key]public string stateValue { get; set; }



    Here I get data in query method but on page entities count is zero.

    Wednesday, September 2, 2009 3:05 AM

All replies

  • Try IEnumerable<State> instead of IQueryable.


    Wednesday, September 2, 2009 9:35 AM
  • Still not working.
    Thursday, September 3, 2009 12:08 AM
  • The problem may be that State is not part of the GISMEDEntities1 domain services, but I am not sure.

    Try using DomainService instead of LinqToEntityDomainService.

    And use IEnumerable<State> as the return type of the query.

    Thursday, September 3, 2009 12:16 AM
  • Hi klinger ,

    It could be right but how to use DomainService instead of LinqToEntityDomainService.

    Thursday, September 3, 2009 12:43 AM
  • Use: 

    public class M_States_DomainService : DomainService


    That should do i.

    Thursday, September 3, 2009 12:47 AM
  • If I do like that,

    I can not get context and get errors.

    Thursday, September 3, 2009 1:12 AM
  • You can always use your entitymodel class to query the database.

    Thursday, September 3, 2009 8:49 AM
  • Hi,

    You can try to make a breakpoint in your customer method, and make sure if it can be reached.

    If not ,you can try to refer this thread: http://silverlight.net/forums/t/121359.aspx

    Monday, September 7, 2009 11:22 PM
  • Hi,

    It reaches the custom methods, even query returns the value from custom methods but when I see count at xaml.cs it shows zero.

    I create one custom class and returns the object of that class.


    Tuesday, September 8, 2009 12:09 AM
  • Share the client side code with us. Maybe you're binding to the wrong object.

    Tuesday, September 8, 2009 2:28 AM
  • Here is my client side code



    public string GetStateValue(string stateCode)


    string state = string.Empty;this.statesContext = new M_States_DomainContext();


    if (!string.IsNullOrEmpty(stateCode))


    EntityQuery<EGT_M_State> stateQuery = this.statesContext.GetStateByStateCodeQuery(stateCode) ;

    LoadOperation<EGT_M_State> stateContex = this.statesContext.Load(stateQuery);


    return state;


    getting stateContex.Cout = 0;

    Tuesday, September 8, 2009 4:20 AM
  • Remember that the Load()-call triggers an asynchronous request to the web server. Pass a callback method in the Load()-method override and wait for the LoadOperation to complete. In the callback you should check the results....

    Tuesday, September 8, 2009 1:01 PM
  • Hi,

    What would be the change in existing code ??

    Wednesday, September 9, 2009 1:16 AM