Click here to Skip to main content
15,885,546 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: Pls Provide me business logic method for reset password or forget password by user id... Pin
Pete O'Hanlon12-Feb-18 8:47
mvePete O'Hanlon12-Feb-18 8:47 
GeneralRe: Pls Provide me business logic method for reset password or forget password by user id... Pin
Richard Deeming12-Feb-18 9:02
mveRichard Deeming12-Feb-18 9:02 
AnswerRe: Pls Provide me business logic method for reset password or forget password by user id... Pin
Richard Deeming12-Feb-18 9:02
mveRichard Deeming12-Feb-18 9:02 
QuestionMessage Removed Pin
12-Feb-18 4:01
Member 1367430012-Feb-18 4:01 
QuestionASP.Net MVC facing difficulties to pass tabular data to action Pin
Mou_kol12-Feb-18 1:49
Mou_kol12-Feb-18 1:49 
QuestionVisual Studio Editor Window Space Rapidly Pin
Priyanka Kale11-Feb-18 21:02
Priyanka Kale11-Feb-18 21:02 
AnswerRe: Visual Studio Editor Window Space Rapidly Pin
A_Griffin12-Feb-18 2:42
A_Griffin12-Feb-18 2:42 
QuestionEntity Framework: How to pass column name dynamically to where clause Pin
Mou_kol10-Feb-18 9:05
Mou_kol10-Feb-18 9:05 
i am curious to know can we pass column name dynamically for where clause.

see a screen shot for searching grid. here is my link [^]

i just got a sample query. please tell me does it work?
C#
public ActionResult Index(String ColumnName,String SearchText)
{

    private CustomersEntities db = new CustomersEntities();

    var customer = (from s in db.Customers
                    select new CustomerDTO
                    {
                    CustomerID = s.CustomerID,
                    CompanyName = s.CompanyName,
                    ContactName = s.ContactName,
                    ContactTitle = s.ContactTitle,
                    Address = s.Address
                    })
    .Where(s => s.Field<string>(ColumnName).ToUpper().Contains(SearchText.ToUpper());

    return View(customer);

}


most of the time i mention column name when search with EF like this way
C#
var query = from s in db.Customers select s;
if (ColumnName == "CompanyName")
            {
                query = query.Where(c => c.CompanyName == SearchText);
            }
            else if (ColumnName == "ContactName")
            {
                query = query.Where(c => c.ContactName == SearchText);
            }


see my screen shot link then you can understand what kind of UI i have to develop. user will select column name from dropdown and put value for search textbox. so when user will hint search button then search need to be done on selected column name. i may have 100 column names in dropdown and it will be huge code if i do it with if..else fashion as i mention here with sample code.

so tell me how could i reduce code for searching where column name will be passed.

looking forward for help and suggestion.

thanks
AnswerRe: Entity Framework: How to pass column name dynamically to where clause Pin
Maciej Los11-Feb-18 0:37
mveMaciej Los11-Feb-18 0:37 
PraiseRe: Entity Framework: How to pass column name dynamically to where clause Pin
Mou_kol11-Feb-18 7:42
Mou_kol11-Feb-18 7:42 
GeneralRe: Entity Framework: How to pass column name dynamically to where clause Pin
Maciej Los11-Feb-18 8:23
mveMaciej Los11-Feb-18 8:23 
QuestionWhy people use .AsEnumerable() along with EF query Pin
Mou_kol10-Feb-18 6:25
Mou_kol10-Feb-18 6:25 
AnswerRe: Why people use .AsEnumerable() along with EF query Pin
User 418025411-Feb-18 3:27
User 418025411-Feb-18 3:27 
GeneralRe: Why people use .AsEnumerable() along with EF query Pin
Mou_kol11-Feb-18 7:44
Mou_kol11-Feb-18 7:44 
AnswerRe: Why people use .AsEnumerable() along with EF query Pin
Nathan Minier12-Feb-18 1:46
professionalNathan Minier12-Feb-18 1:46 
QuestionAzure csv radgrid dataset bind attempt Pin
jsegreti10-Feb-18 4:39
jsegreti10-Feb-18 4:39 
QuestionAdd a Nuget Package Using dotnet add Pin
Priyanka Kale9-Feb-18 21:43
Priyanka Kale9-Feb-18 21:43 
AnswerRe: Add a Nuget Package Using dotnet add Pin
User 418025411-Feb-18 3:22
User 418025411-Feb-18 3:22 
QuestionVSOT vb.net Pin
kumardm93289-Feb-18 15:45
kumardm93289-Feb-18 15:45 
AnswerRe: VSOT vb.net Pin
User 41802549-Feb-18 16:56
User 41802549-Feb-18 16:56 
GeneralRe: VSOT vb.net Pin
kumardm93289-Feb-18 17:40
kumardm93289-Feb-18 17:40 
AnswerRe: VSOT vb.net Pin
Richard Deeming12-Feb-18 9:08
mveRichard Deeming12-Feb-18 9:08 
QuestionVideo hosting on asp.net MVC application Pin
User 41802549-Feb-18 11:29
User 41802549-Feb-18 11:29 
QuestionDashboard Build in .net with Bootstrap Pin
RekhaDhankhar9-Feb-18 6:13
RekhaDhankhar9-Feb-18 6:13 
AnswerRe: Dashboard Build in .net with Bootstrap Pin
User 41802549-Feb-18 12:33
User 41802549-Feb-18 12:33 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.