assign the unique row a typedList.Select method to an object that has "field property" intellisense

Posts   
 
    
yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 16-May-2007 14:22:12   

version 1.0.2005.1 final (self-servicing) VS2005 asp.net 2.0


hiya,

I am performing a "select" on a typedList. I know that the select statement will return a SINGLE, unique row because the select is a GUID: eg

currRow = tListCategoryCrumbs.Select("categoryGUID ='" + categoryGUID+ "'");

Is there any way that I can assign currRow as a datatype that will give me the intellisense that I would have if i was working with an entity?

so that intellisense would give me... currRow.ParentId currRow.categoryGUID

I have tried to assign the return value of the select method to an entity, but that didn't work.

dalHamilton.EntityClasses.CskStoreCategoryEntity fg = new CskStoreCategoryEntity();
 fg = tListCategoryCrumbs.Select("categoryGUID =" + g)[0];  

any ideas?

many thanks,

yogi

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 16-May-2007 15:27:30   

I have tried to assign the return value of the select method to an entity, but that didn't work.

You may create an entity, and populate its fields with data from the selected Row.

yogiberr
User
Posts: 432
Joined: 29-Jun-2005
# Posted on: 16-May-2007 18:29:30   

righto, thanks Walaa. I thought there might have been an easier way.Instaed, I opted just to use the datarow and access the values by field name inside quotes.

cheers,

yogi

simmotech
User
Posts: 1024
Joined: 01-Feb-2006
# Posted on: 17-May-2007 06:48:11   

yogiberr wrote:

righto, thanks Walaa. I thought there might have been an easier way.Instaed, I opted just to use the datarow and access the values by field name inside quotes.

cheers,

yogi

Every generated TypedList, which inherits from DataTable, also has a generated typed row with properties for all of the fields - look in the TypedList class file for the exact name which is I think the same as the TypedList name but with "Row" at the end rather than "TypedList".

So you should be able to use something like:

CategoryCrumbsRow fg = (CategoryCrumbsRow) tListCategoryCrumbs.Select("categoryGUID =" + g)[0];
Console.WriteLine(fg.ParentID);

and get intellisense too. Note the cast, this is because Select is from DataTable and so returns DataRow[] but really these will be typed rows.

Cheers Simon