C
C#14mo ago
l3pord

❔ Implementation of Search page in ASP. NET MVC along with stored procedure

Can anyone help me to create a webform to search the data from the database to filter it on web page. Let suppose the data is an Employee table or a product table. And I want an webpage by which I can search this data is available on the database or not?
No description
15 Replies
l3pord
l3pordOP14mo ago
Consider this is the table
Leonardo
Leonardo14mo ago
ok i dont think i got it straight but i will literally say what i understood: 1# scenario (that i understood) you want to create a page which lists your table (duh) BUT you want to list only the AVAILABLE ITEMS. in that case you would need to add a new column there as boolean or int whatever suits better to you you can call that column as isactive or something like that idk and basically the items which has that column as 1 are the active ones and the ones that has it as 0 are the inactives (duh 2) and your select query should look like this select * from cooltablename ctn where ctn.isactive = 1 in case you are using ef/linq it should look like this list.Where(x => x.isactive == true).ToList() if i got it wrong sorry im dumb now if you are looking on creating a search bar then thats a little more different
l3pord
l3pordOP14mo ago
Let me explain again.....)
Leonardo
Leonardo14mo ago
sure im all ears
l3pord
l3pordOP14mo ago
Consider the above table as that is Product table Refer to product table above and implement a Search page in ASP.MVC along with stored procedure in backend (db). Please follow below points while developing solution for given requirement. 1. Search Criteria needs to be developed at both frontend & backend for following fields a. ProductName b. Size c. Price d. MfgDate e. Category 2. UI should provide option to define search criteria using any combination of 1 or more fields specified in point 1.(i.e. Search criteria can be specified using 1 field, 2 field or all fields) 3. If two or more fields are used in search criteria then an option should be provided in UI to specify the conjunction between two conditions(i.e. AND , OR) 4. Also provide option to clear/reset the search criteria. 5. Show the Search results in grid/table in UI. 6. Develop the stored procedure that satisfies all the conditions provided by UI. Now I hope this is clear to you?
Leonardo
Leonardo14mo ago
yeah i think now fits more with the second scenario that i got in mind
l3pord
l3pordOP14mo ago
Yeah What could be your second scenario I have created a controller and Model
3R1C
3R1C14mo ago
I understand you might enjoy doing what you're doing, but have you ever considered using code first?
Leonardo
Leonardo14mo ago
ok so rn i cant right anything to give as an example but you can do a search method using sql like function where you will receive a parameter as the word which the user will input in the ui and then you can search or filter through it, ik its not well explained but try that as a proof of concpet create an endpoint where it requrires a string value and that string value will be used as the like search value see if the results matches thats a solution in case you are using dapper or sql command direclty
Leonardo
Leonardo14mo ago
for ef core you can find something like contains maybe i havent tried it with ef only yet https://stackoverflow.com/questions/45708715/entity-framework-ef-functions-like-vs-string-contains
Stack Overflow
Entity framework EF.Functions.Like vs string.Contains
I was reading the announcement of entity framework core 2.0 https://blogs.msdn.microsoft.com/dotnet/2017/08/14/announcing-entity-framework-core-2-0/ It says that they added new Sql functions like EF.
Leonardo
Leonardo14mo ago
first thing i would make is a pilot endpoint which receives a string and returns object by that initial string
l3pord
l3pordOP14mo ago
Ok! Let me try Once done I'll share the github url for review
Leonardo
Leonardo14mo ago
sure
Accord
Accord14mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server