0
votes

I have an entity ex: A and it has a related "X_Message" entity for which X_MessageSet is created in the ServiceContext class created by crmsvcutil tool.

When I use this I get error "the specified type X_message is not a known entity type" and this exception happens in LINQ code.

This is happening in our ServiceContext class which is XRMServiceContext.

Class which we are using to create instance of Context:

    public CrmServiceProxy(IOrganizationService orgService)
    {
        _orgService = orgService;
        context = new XrmServiceContext(this._orgService);
    }


     public System.Linq.IQueryable<XXX.X_message> X_messageSet
    {
        get
        {
            return this.CreateQuery<XXX.X_message>();
        }
    }

When I debugging my Plugin, I am seeing that "context" is having this X_messageset as a property but its giving System.ArgumentException, so am unable to debug too.

Please help.

1

1 Answers

0
votes

are you sure you are using the "context" variable you set up?

I find it easiest to do this:

using (var srv = new XrmServiceContext(_orgService)){
    List<new_entity> e = srv.new_entitySet.Where(e => e.Id == passedInId).ToList();
//Do Stuff with your list
}

where 'new_entity' is the name of the entity, "Where" is returning me all "new_entity" records that meet the condition specified (the id equals "passedInId" in this example)