StrataFrame Forum

BO.GetEnumerable in web page

http://forum.strataframe.net/Topic20455.aspx

By Hugo R. Figueroa - 10/30/2008

Hi,

I am trying to use GetEnumerable with a Business Object in a web page like this:

foreach ( Serv_ClosedBO mBO in Serv_Closed.GetEnumerable())

but when I try to build the web site, I get an error that says:

" The type of namespace name 'Serv_CLosedBO' could not be found (are you missing  a using directive or an assembly reference?)  "

 

The BO is declared in the corresponding applicationbasepage,

 

 Can I use GetEnumerable in web pages? what am I missing?

 

 

 

 

 

 

By Greg McGuffey - 10/30/2008

Hugo,



I think the problem is that GetEnumerable isn't a shared (static) method. It is an instance method. Thus you need to call it on the BO you want to enumerate, not on the BO Type itself. I.e.



// This won't work, calling GetEnumerable on type

foreach ( Serv_ClosedBO mBO in Serv_Closed.GetEnumerable())



// Use something like this instead

Serv_ClosedBO mainBO = new Serv_ClosedBO();

foreach ( Serv_ClosedBO mBO in mainBO.GetEnumerable())





Obviously, you would use the approriate BO to enumerate that you've setup in your master page. This is just a sample to demonstrate that you call GetEnumerable on an instance.



Hope that helps!


By Hugo R. Figueroa - 10/30/2008

I am lost now .

BOs are not supposed to be instantiated in applicationbasepage and so be available in my page?

Crying

By Hugo R. Figueroa - 10/30/2008

Well now I am "using" the namespace where the business objects are, and problem solved (at least I can compile).
By Greg McGuffey - 10/30/2008

Yep, 'using' the namespace of your BOs would help! Tongue



I didn't read your original post closely enough and thought you had used the type (Serv_ClosedBO) with GetEnumerable(), but in fact you hadn't... oops Blush



Glad you got it going! BigGrin
By Hugo R. Figueroa - 10/30/2008

Thank you