0

Suppose I have a Table name AutoPurge with 2 columns ID (identity) and Parameter. There are 4 records in this table - a, b, c and d.

Assume, I wish to display this 4 value in a table format in an MVC application. So I pass this following code to the view from my controller.

        //AutoPurge is table
        return View(await _context.AutoPurge.ToListAsync());

So by right, this will display all 4 values (a, b, c and d described above) in a table format in my View. If i only want to display all the rows (a, b, c) except the row "d", may I ask how can i code for this?

2 Answers 2

1

This can be done by applying a predicate to your query, very much like you would do in SQL:

var result = await _context.AutoPurge.Where(x => x.Id != "d").ToListAsync();
return View(result);

You have to change that predicate to your definition, since I don't know how you want to filter specifically.

Sign up to request clarification or add additional context in comments.

Comments

0

Execute query excluding that specific value i.e.: SELECT * FROM AutoPurge A WHERE A.Parameter NOT IN ('d') or filter the ArrayList after returning all the records using C#. new ArrayList(CompleteList.Cast<List>().Where(d => d.VID != "d").ToList());

Hope it will work.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.