none
Unable to create a constant value of type 'System.Object'. Only primitive types or enumeration types are supported in this context. RRS feed

  • Question

  • List<clsPermissionsCode> lstMap = (from tblMap in objData.tblEmp_Mappings
                                               join tblUserPermissions in objData.tblUserPermissions
                                               on tblMap.EnrollNo equals tblUserPermissions.EnrollNo
                                               join tblDevice in objData.tblDeviceMasters
                                               on tblUserPermissions.DeviceId equals tblDevice.DeviceId
                                               where tblUserPermissions.active.Equals(true)
                                               select new clsPermissionsCode
                                               {
                                                   DeviceId = tblUserPermissions.DeviceId,
                                                   UserPermissionId = tblUserPermissions.UserPermissionId,
                                                   DeviceName = tblDevice.ComputerName,
                                                   DevicePermission = tblUserPermissions.DevicePermission,
                                                   EnrollNamePrefix = tblUserPermissions.EnrollNamePrefix,
                                                   EnrollNo = tblUserPermissions.EnrollNo,
                                                   EmpId=Convert.ToInt32(tblMap.EmployeeId),
                                                   MapId=Convert.ToInt32(tblMap.MappingId),
                                                   Active=tblUserPermissions.active.Value,
                                                   Connected = true
                                               }).ToList();
    Saturday, April 4, 2015 12:33 PM

Answers

  • Hello Yogesh,

    Please have a try to replace

    where tblUserPermissions.active.Equals(true)

    with:

    where tblUserPermissions.active == true

    Or if your active column is nullable, change it to non-nullable, then try to use

    where tblUserPermissions.active.Equals(true)

    This is a IQueryable query, so it would try to translate the LINQ query to the TSQL and the Bool?.Equals(Bool) syntax is not recognized by the LINQ to Entities provider.

    I notice that you use the Convert.ToInt32() method in the LINQ query, please note this is also recognized by the LINQ to Entities. For details, you could refer to this link:

    http://stackoverflow.com/questions/18637985/linq-to-entities-does-not-recognize-the-method-int32-toint32-converting-string

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, April 6, 2015 6:36 AM
    Moderator