Column Comparison Datatype in OrWhere

Column Comparison Datatype in OrWhere

kmboninkmbonin Posts: 59Questions: 16Answers: 0

I'm doing an OrWhere on a select list option list in my controller (.net).

.Field(new Field("tasks.resourceID")
                        .Options("users_master", "userID_DVPR", "fullName", q => q.Where("roleID", "4", "<>").OrWhere("users_master.userID", "tasks.resourceID",  "="))
                        .Validator(Validation.DbValues()))

I'm trying to populate the select list with the resource (even if they are a deleted user, would be default selected) OR all users that are not deleted. The error I get is on the OrWhere when comparing the two fields - userID is an INT, resourceID is an INT in the database but has been converted to a string (I believe) in the JSON.

How can I compare the same datatypes in the OrWhere?

Answers

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin

    It looks like you want the content of the select to be dependent on whatever the value of tasks.resourceID is. Is that the case? If so, you'll need to use dependent() to make an Ajax call to the server whenever the select changes value (this blog post shows how that can be done).

    The Options will only make a query to the users_master table - it doesn't know anything about the host tasks table, which it why this arises. If you consider that each task.resourceID might have different options available to it, that's way it needs to get data from the server for each value.

    Allan

This discussion has been closed.