This question is locked. New answers and comments are not allowed.
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:
Any ideas on how to solve this??
Thanks in advance.
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.