I cant make a full dynamic query in LINQ
I have 2 situation methods (only_exp_query , only_tbl_query) those are
working.
....
using System.Linq.Dyn amic;
using System.Data.Lin q;
....
string connString = @"Data Source=.;Initia l
Catalog=Northwi nd;Integrated Security=True";
DataClasses1Dat aContext db = new
DataClasses1Dat aContext(connSt ring);
....
private void only_exp_query( )
{
Table<Customer_ customer = db.Customers;
var query = db.Customers
.Where("City=@0 ", "LONDON")
.OrderBy("Compa nyName");
dataGridView1.D ataSource = query;
}
private void only_tbl_query( )
{
Table<Customer_ customer = db.Customers;
var query = from tbl in _customer
select tbl;
dataGridView1.D ataSource = query;
}
But i want to run the script below , but it is not working...
private void full_query()
{
Table<Customer_ customer = db.Customers;
var query = db.Customers
.GetTable("Cust omers")
.Where("City=@0 ", "LONDON")
.OrderBy("Compa nyName");
dataGridView1.D ataSource = query;
}
and then i can try this below script...
private void full_query()
{
Assembly asm =
Assembly.GetAss embly(typeof(Da taClasses1DataC ontext));
var query = db.GetTable(asm .GetType("Custo mer"));
.Where("City == @0 and Orders.Count >= @1", "London", 10)
.OrderBy("Compa nyName, City")
.Select("New(Co mpanyName as Name, Phone)");
dataGridView1.D ataSource = query;
}
but it returns the following error:
"ArgumentNullEx ception was unhandled ,Value Cannot be null,Parameter Type"
but i dont know this error.
WHAT CAN I DO?
can you help me please
Comment