var q = (from z in JumpTideClassLib.jumptidexml.GetOverviewProductsLong(thisX, "tblProductoverview")
where z.Name3 == p.Name3
select new { Name1 = z.Name1, Name3 = p.Name3})
var q = (from z in JumpTideClassLib.jumptidexml.GetOverviewProductsLong(thisX, "tblProductoverview")
where z.Name3 == p.Name3
select new { Name1 = z.Name1, Name3 = p.Name3})
You must have a class with properties contain Name1, and Name3. Again you must have a class.
The above "var" make the class to be type of "q" automaticaly
No。You can never fetch an anoymous class with its className and other things……You must create another class as a holder to hold it and then you can fetch from RepeateItem to convert to this class:
public class Class1
{
public string Name1{get;set;}
public string Name2{get;set;}
public string Name3{get;set;}
}
var q = (from z in JumpTideClassLib.jumptidexml.GetOverviewProductsLong(thisX, "tblProductoverview") where z.Name3 == p.Name3 select new Class1{ Name1 = z.Name1, Name3 = p.Name3})
Jelmer850i
Member
232 Points
1053 Posts
linq question
Apr 13, 2012 08:11 PM|LINK
a linq question:
i need to write a code without a class.
So:
var q = (from z in JumpTideClassLib.jumptidexml.GetOverviewProductsLong(thisX, "tblProductoverview")
where z.Name3 == p.Name3
select new { Name1 = z.Name1, Name3 = p.Name3})
repTypes.DataSource = q;
But i've got a
protected void RepTypes_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
with a class name.
so how should i access the var's withouth a class name?
jsiahaan
Contributor
2304 Points
588 Posts
Re: linq question
Apr 13, 2012 09:17 PM|LINK
Hi,
You must have a class with properties contain Name1, and Name3. Again you must have a class.
The above "var" make the class to be type of "q" automaticaly
Have fun
Indonesian Humanitarian Foundation
Gaspard
Contributor
2066 Points
416 Posts
Re: linq question
Apr 13, 2012 09:40 PM|LINK
This thread may help
http://stackoverflow.com/questions/1070526/how-to-return-anonymous-type-from-c-sharp-method-that-uses-linq-to-sql
Regards
Jelmer850i
Member
232 Points
1053 Posts
Re: linq question
Apr 14, 2012 08:42 AM|LINK
The problem is that if i make a class of it the repeater gets a lot more then without the var.
So with the variabele: 123 items, withouth the variabele 3 items........
So how can i process this without a class/variabele? So like above .
Decker Dong ...
All-Star
118619 Points
18779 Posts
Re: linq question
Apr 15, 2012 03:12 AM|LINK
No。You can never fetch an anoymous class with its className and other things……You must create another class as a holder to hold it and then you can fetch from RepeateItem to convert to this class:
public class Class1 { public string Name1{get;set;} public string Name2{get;set;} public string Name3{get;set;} }