where condition not a field .net
where condition not a field .net
I am filtering a second datatable based off a selected row of the first database. However, if there is nothing selected on the first datatable, I would like the second datatable to show all records. Is this possible? Currently, if unselected I am settting it to -1.
            ajax: {
                url: '/api/Contacts',
                type: 'post',
                data: function (d) {
                    var selected = applicationtable.row({ selected: true });
                    if (selected.any()) {
                        d['Contacts.ApplicationID'] = selected.data().ApplicationID;
                    } else {
                        d['Contacts.ApplicationID'] = -1;
                    }
                }
            },
it doesn't like the orWhere because it is expecting a fieldname
                                .Where(q =>
                                {
                                    q.Where(r =>
                                    {
                                        r.Where("Contacts.ApplicationID", request.Form["Contacts.ApplicationID"]);
                                        r.OrWhere(request.Form["Contacts.ApplicationID"],"-1");
                                    });
                                })
                This question has an accepted answers - jump to answer
This discussion has been closed.
            
Answers
I'd say only add the
Wherecondition if the value of the application id is not -1, unless I've misunderstood?Allan
thank you so much. I should have thought of that!!