This is a migrated thread and some comments may be shown as answers.
Anonymously Hosted DynamicMethods Assembly - ERROR
2 Answers 101 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Top achievements
Rank 1
Eduardo asked on 14 Feb 2013, 08:02 PM
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 Answers, 1 is accepted

Sort by
Viktor Zhivkov
Telerik team
answered on 19 Feb 2013, 12:02 PM
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.
Top achievements
Rank 1
answered on 21 Apr 2014, 05:19 PM
Thanks for the awesome information. It helped solve a hard problem. 
LINQ (LINQ specific questions)
Asked by
Top achievements
Rank 1
Answers by
Viktor Zhivkov
Telerik team
Top achievements
Rank 1
Share this question