Anonymously Hosted DynamicMethods Assembly - ERROR

Thread is closed for posting
3 posts, 0 answers
  1. Eduardo
    Eduardo avatar
    9 posts
    Member since:
    Feb 2009

    Posted 14 Feb 2013 Link to this post

    Hi, i have a linq query that when try to execute i got the exception: "Object reference not set to an instance of an object." and the source: "Anonymously Hosted DynamicMethods Assembly".

    Mi code is:
    SigesoftEntitiesModel dbContext = new SigesoftEntitiesModel();
    string pstrFilterExpression = "v_Name.Contains(\"alus\")";
    IQueryable<WarehouseList> query;
    query =    from A in dbContext.Warehouses
                        join J1 in dbContext.SystemUsers on new { i_InsertUserId = A.i_InsertUserId.Value } equals new { i_InsertUserId = J1.i_PersonId } into J1_join
                        from J1 in J1_join.DefaultIfEmpty()
                        join J2 in dbContext.SystemUsers on new { i_UpdateUserId = A.i_UpdateUserId.Value }  equals new { i_UpdateUserId = J2.i_PersonId } into J2_join
                        from J2 in J2_join.DefaultIfEmpty()
                        where   A.i_OrganizationId == pintOrganizationId
                                && (J1.i_NodeId == 1 || J1.i_NodeId == null)
                                && (J2.i_NodeId == 1 || J2.i_NodeId == null)
                        select new WarehouseList
                              i_WarehouseId = A.i_WarehouseId,
                              v_Name = A.v_Name,
                              v_CreationUser = J1.v_UserName,
                              d_CreationDate = A.d_InsertDate,
                              v_UpdateUser = J2.v_UserName,
                              d_UpdateDate = A.d_UpdateDate,
                              v_AdditionalInformation = A.v_AdditionalInformation,
                              i_IsDeleted = A.i_IsDeleted,
                              i_OrganizationId = A.i_OrganizationId
    if (!string.IsNullOrEmpty(pstrFilterExpression))
           query = query.Where(pstrFilterExpression);
    List<WarehouseList> objData = query.ToList();   // Here is when the exception raises !!!

    Any ideas on how to solve this??
    Thanks in advance.
  2. Viktor Zhivkov
    Viktor Zhivkov avatar
    324 posts

    Posted 19 Feb 2013 Link to this post

    Hi Eduardo,

    I believe that the problem with your query is a null value in v_Name projected column.
    In order to fix your query you should modify your code in the following way:
    string pstrFilterExpression = "v_Name != null && v_Name.Contains(\"alus\")";

    Please note that this code will be executed on the client side!

    If you need any further assistance do not hesitate to contact us.

    All the best,
    Viktor Zhivkov
    the Telerik team
    Q3'12 SP1 of OpenAccess ORM packs Multi-Table Entities mapping support. Check it out.
  3. Phil
    Phil avatar
    1 posts
    Member since:
    Nov 2012

    Posted 21 Apr 2014 in reply to Viktor Zhivkov Link to this post

    Thanks for the awesome information. It helped solve a hard problem. 
Back to Top