M
Mucahit ikiz
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.Dynamic;
using System.Data.Linq;
....
string connString = @"Data Source=.;Initial
Catalog=Northwind;Integrated Security=True";
DataClasses1DataContext db = new
DataClasses1DataContext(connString);
....
private void only_exp_query()
{
Table<Customer> _customer = db.Customers;
var query = db.Customers
.Where("City=@0", "LONDON")
.OrderBy("CompanyName");
dataGridView1.DataSource = query;
}
private void only_tbl_query()
{
Table<Customer> _customer = db.Customers;
var query = from tbl in _customer
select tbl;
dataGridView1.DataSource = 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("Customers")
.Where("City=@0", "LONDON")
.OrderBy("CompanyName");
dataGridView1.DataSource = query;
}
and then i can try this below script...
private void full_query()
{
Assembly asm =
Assembly.GetAssembly(typeof(DataClasses1DataContext));
var query = db.GetTable(asm.GetType("Customer"));
.Where("City == @0 and Orders.Count >= @1", "London", 10)
.OrderBy("CompanyName, City")
.Select("New(CompanyName as Name, Phone)");
dataGridView1.DataSource = query;
}
but it returns the following error:
"ArgumentNullException was unhandled ,Value Cannot be null,Parameter Type"
but i dont know this error.
WHAT CAN I DO?
can you help me please
I have 2 situation methods (only_exp_query, only_tbl_query) those are
working.
....
using System.Linq.Dynamic;
using System.Data.Linq;
....
string connString = @"Data Source=.;Initial
Catalog=Northwind;Integrated Security=True";
DataClasses1DataContext db = new
DataClasses1DataContext(connString);
....
private void only_exp_query()
{
Table<Customer> _customer = db.Customers;
var query = db.Customers
.Where("City=@0", "LONDON")
.OrderBy("CompanyName");
dataGridView1.DataSource = query;
}
private void only_tbl_query()
{
Table<Customer> _customer = db.Customers;
var query = from tbl in _customer
select tbl;
dataGridView1.DataSource = 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("Customers")
.Where("City=@0", "LONDON")
.OrderBy("CompanyName");
dataGridView1.DataSource = query;
}
and then i can try this below script...
private void full_query()
{
Assembly asm =
Assembly.GetAssembly(typeof(DataClasses1DataContext));
var query = db.GetTable(asm.GetType("Customer"));
.Where("City == @0 and Orders.Count >= @1", "London", 10)
.OrderBy("CompanyName, City")
.Select("New(CompanyName as Name, Phone)");
dataGridView1.DataSource = query;
}
but it returns the following error:
"ArgumentNullException was unhandled ,Value Cannot be null,Parameter Type"
but i dont know this error.
WHAT CAN I DO?
can you help me please