Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > LINQ
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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??
 
Old April 18th, 2009, 07:32 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 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!
 
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,





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 02:10 PM
Property/Method access using string values jaucourt VB.NET 2002/2003 Basics 1 February 10th, 2004 01:05 PM
Access to a property in the class. AyatKh ASP.NET 1.0 and 1.1 Basics 2 December 18th, 2003 11:25 AM
Access stay in memory with .ColumnWidth property xmasm1 Access VBA 3 August 19th, 2003 07:02 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.