This question is locked. New answers and comments are not allowed.
var wherePart = "q.SkuUid == SkuUid and q.SalesType == SalesType"; |
var getIt = from q in query |
where wherePart |
select q; |
Is dynamic LINQ, like the above, included in Q1 2009?
5 Answers, 1 is accepted
0
Hi Bo Hessner,
dynamic LINQ is supported, but the example given by you must be slightly rewritten:
var getIt = scope.Extent<Bo>()
.Where("SkuUid == @SkuUid and SalesType == @SalesType", 1234, 5678);
So the entire query cannot be made up by string concatenation, but string pieces must be given along with the parameters in the right order.
You might want to check this link also : Dynamic LINQ .
Kind regards,
Alexander
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
dynamic LINQ is supported, but the example given by you must be slightly rewritten:
var getIt = scope.Extent<Bo>()
.Where("SkuUid == @SkuUid and SalesType == @SalesType", 1234, 5678);
So the entire query cannot be made up by string concatenation, but string pieces must be given along with the parameters in the right order.
You might want to check this link also : Dynamic LINQ .
Kind regards,
Alexander
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hi Hessner,
There was a little misunderstanding in our last letter to you. The format of the dynamic Linq query should be slightly different:
var getIt = scope.Extent<Bo>()
.Where("SkuUid == @0 and SalesType == @1", 1234, 5678);
The thing is that named parameters are not supported at the moment with OpenAccess and numbed parameters should be used instead.
Again we are sorry for the inconvenience.
All the best,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
There was a little misunderstanding in our last letter to you. The format of the dynamic Linq query should be slightly different:
var getIt = scope.Extent<Bo>()
.Where("SkuUid == @0 and SalesType == @1", 1234, 5678);
The thing is that named parameters are not supported at the moment with OpenAccess and numbed parameters should be used instead.
Again we are sorry for the inconvenience.
All the best,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hessner
Top achievements
Rank 2
answered on 17 Mar 2009, 01:39 PM
Regarding:
var getIt = scope.Extent<Bo>()
.Where("SkuUid == @SkuUid and SalesType == @SalesType", 1234, 5678);
My real "where part" contain fields from several tables, how is this done?
var getIt = scope.Extent<table1 Join table2 Join table3 >?
.Where("table1.SkuUid == @SkuUid and table2.SalesType == @SalesType", 1234, 5678);
var getIt = scope.Extent<Bo>()
.Where("SkuUid == @SkuUid and SalesType == @SalesType", 1234, 5678);
My real "where part" contain fields from several tables, how is this done?
var getIt = scope.Extent<table1 Join table2 Join table3 >?
.Where("table1.SkuUid == @SkuUid and table2.SalesType == @SalesType", 1234, 5678);
0
Accepted
Hello Hessner,
You should just point the references in the where clause like in the sample bellow which is based on the
Northwind database.
All the best,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
You should just point the references in the where clause like in the sample bellow which is based on the
Northwind database.
var result = scope.Extent<Order>() |
.Where("Customer.CustomerID == @0 and Employee.EmployeeID==@1 ", "ALFKI",1); |
All the best,
Zoran
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Hessner
Top achievements
Rank 2
answered on 17 Mar 2009, 10:25 PM
I got it - this work out fine:
var condition = string.Format("PortalID == {0}", Utilities.CurrentPortalid()); |
var result = os.Extent<UserRole>().Where(condition).Select("new (User.UserID, User.Email, User.FuldeNavn, Medlemsnummer, Role.RoleName, SidsteLogon)"); |
RadGrid1.DataSource = result; |