Hello all,
I need a bit of inspiration from somewhere and hoping someone, anyone could help.
This stems from a previous thread i created whereby I want to be able to do a autocomplete search on a complete data table i.e. all the data from all the columns.
I have created a stored procedure that pulls together the autocomplete items and the columns these items are derived from i.e.
tblAutoCompleteItems:
Item Column
Item1 Product
Item2 Product
Item3 Product
Red Category1
Green Category1
Blue Category1
Small Category2
Medium Category2
Large Category2
I've sorted the textbox autocomplete and that works fine. Based upon the client selection, a label displays which associated column this item is generated from (so the client can check they are happy with what their search will return). Lovely.
However, the tricky bit, and the bit I need help with, is pulling back another data set based upon the criteria they have selected. The other data set looking something along the lines of...
tblProductInfo:
Product Category1 Category2
Item1 Red Big
Item2 Red Small
Item3 Blue Small
For example, a user autocompletes for 'Item1', the textbox shows this and the label displays 'Product' Alternatively, a user may want to search by Category1 so searches for 'Red', this is presented in the text box and the label displays 'Category1'
When looking at tblProductInfo, I need to somehow query the dataset so that it looks at the autocomplete column and the autocomplete item.
So when I hit a button or whatever, the linq looks at the column first, says "oh I know, I need to look at Category1 and then pull back anything with Red in it" or "ok that's a Product, I'll head over to the Product column first and then pull back the data associated with Item1"
I'm struggling in two parts (1) How to access the column names within a table and (2) construct the where clause in the linq.
Any help, tips or advice gratefully received - even if it means a complete strategy rethink.
I'm attmepting this using c#, LINQ and asp.net.
By the by - I realise it is not ideal having the autocomplete look across a complete table but this is out of my hands...sadly.