By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,313 Members | 2,725 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,313 IT Pros & Developers. It's quick & easy.

I cant make a full dynamic query in LINQ

P: n/a

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(DataClasses1DataContex t));

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
Jul 7 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
First thought; one of the primary aims of LINQ is to provide things
like compile-time checking to expressions, and a better development
experience. By going down a fully dynamic route, you're not really
getting many of those benefits... so an I ask (out of curiosity) why
regular LINQ isn't an option here? There may be better ways of doing
what you want.

Marc
Jul 8 '08 #2

P: n/a
This problem was solve.

that
Assembly asm = Assembly.GetAssembly(typeof(DataClasses1DataContex t));
var query = db.GetTable(asm.GetType("Customer"));

we change this row
Table<Customer_customer = this.Context.GetTable( typeof(Customer) ) as
Table<Customer>;"Mucahit ikiz" <mu**********@sifas.com.trwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>
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(DataClasses1DataContex t));

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

Jul 8 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.