Using system;
Using system. collections;
Using system. configuration;
Using system. Data;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. htmlcontrols;
Using system. Web. UI. webcontrols;
Using system. Data;
Using system. LINQ;
Using system. reflection;
Using system. Collections. Generic;
Public Class
{
Public A (string Arg)
{
Field = ARG;
}
Public String Field
{
Get;
Set;
}
}
Public partial class test: system. Web. UI. Page
{
// enter the field name and field value for query
private void linqdynamicquery (string fieldname, string fieldvalue)
{< br> List O = new list ();
O. add (new A ("ABCD");
O. add (new A ("abcd123");
O. add (new A ("abcd245");
O. add (new A ("3222bcd");
VaR qry = from P in O
Where system. componentmodel. typedescriptor. getproperties (p) [fieldname]. getvalue (P). tostring (). Contains (fieldvalue)
Select P;
System. Diagnostics. Debug. Assert (false, qry. Count (). tostring ());
}
Protected void page_load (Object sender, eventargs E)
{
Linqdynamicquery ("field", "ABC ");
}
}