Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > .NET > Other .NET > LINQ
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
LINQ Discuss Microsoft's LINQ (Language INtegrated Query) for .NET 3.0 and later.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the LINQ section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old April 17th, 2009, 07:06 PM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default How do I access a property?

1.in my aspx page, i have this:
var result = from p in sCalculator.test(rule.CalculatorId)
select new OrderP.ScoreCalculator { typeName = p.TypeName, name = p.Name };

2. In my sCalculator, i have this:
public String typeName { get; set; }
public String name { get; set; }
public List<ScoreCalculator> test(Guid id)
{
var q =
from i in this.Context.ScoreCalculator
where i.Id == id
select i;

return q.ToList();
}

3.**** Now, In ScoreRule.cs, (another file), i want to access "name" and "type" name. How do I do this??
  #2 (permalink)  
Old April 18th, 2009, 07:32 AM
Imar's Avatar
Wrox Author
Points: 71,768, Level: 100
Points: 71,768, Level: 100 Points: 71,768, Level: 100 Points: 71,768, Level: 100
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,033
Thanks: 80
Thanked 1,582 Times in 1,559 Posts
Default

Hi there,

The type of result is an IEnumerable<T> or something that derives from it, You can use a foreach to loop over the items:

Code:
 
var result = from p in sCalculator.test(rule.CalculatorId)
     select new OrderP.ScoreCalculator { typeName = p.TypeName, name = p.Name };

foreach (var item in result)
{
  // here you can access item.Name;
}
Hope this helps,

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
  #3 (permalink)  
Old April 18th, 2009, 08:28 AM
Authorized User
 
Join Date: Dec 2008
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i will try and post back. Thanks,
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
ERROR: "property access must assign to the proper" anpham ASP.NET 1.0 and 1.1 Basics 2 July 1st, 2005 02:25 PM
Access a Project's Property Pages Programmatically Jim Rogers Pro VB 6 0 March 2nd, 2004 01:10 PM
Property/Method access using string values jaucourt VB.NET 2002/2003 Basics 1 February 10th, 2004 12:05 PM
Access to a property in the class. AyatKh ASP.NET 1.0 and 1.1 Basics 2 December 18th, 2003 10:25 AM
Access stay in memory with .ColumnWidth property xmasm1 Access VBA 3 August 19th, 2003 07:02 AM



All times are GMT -4. The time now is 12:54 PM.


Powered by vBulletin®
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.