views:

130

answers:

2

in my silverlight page I am fetching the data through WCF
WCF is returning an BusinessEntityCollection that is the collection of rows

SqlParameter[] sqlParameter = new SqlParameter[]{new SqlParameter("@recordType",recordType)};
MenuEntity menuEntity;
MenuEntityCollection menuEntityCollection = new MenuEntityCollection();
using (SqlDataReader sqlDataReader = SqlHelper.ExecuteReader(_ConnectionString,CommandType.StoredProcedure,
StoredProcedures.GetMenus, sqlParameter))
{
if (sqlDataReader.Read())
{
menuEntity = new MenuEntity();
DataAccessHelper.GetEntity(sqlDataReader, menuEntity);
menuEntityCollection.Add(menuEntity);
}
}
return menuEntityCollection;


--> in silverlight page when I am calling WCF there I am getting an error
MenuEntity menuList = new MenuEntity();
menuList = e.Result; <-----error line

error: Cannot implicitly convert type
'System.Collections.ObjectModel.ObservableCollection' to 'FastTrackSLUI.AdminServiceReference.MenuEntity'

+1  A: 

It is returning a collection, but you are treating it as a single instance (menuList is typed as MenuEntity, not some kind of collection). Is the WCF code generated from the "mex"? It should just work... If that is your code, try changing menuList to ObservableCollection<MenuEnity>. Note that over "mex" / soap / etc you don't get the real objects back - you get lightweight proxies. So your custom collection types may have evaporated.

Marc Gravell
ya I know thats why I am saying MenuEntityCollection option is not coming in my intellisence.
nectar
hi marc thanks for ur responsenow I have collection at silverlight page alsoAdminServiceClient proxy = new AdminServiceClient(); proxy.GetMenusCompleted += new EventHandler<GetMenusCompletedEventArgs>(proxy_GetMenusCompleted); proxy.GetMenusAsync();MenuEntityCollection menuList = new MenuEntityCollection(); menuList = e.Result;how can I access records in menuList ?
nectar
A: 

write line [CollectionDataContract] before the MenuEntityCollection Class--

[CollectionDataContract] public class MenuEntityCollection : BusinessEntityCollectionBase { public MenuEntityCollection() { } }

now it is working.

nectar