This project is read-only.

EntityCombo load unsave data

Jan 21, 2010 at 6:50 PM

Hello, I has trying to set some data in a EntityCombo, so I set




private IList divisionsList = null;


private IEnumerable<Lazy> divisions_LoadData()
            return this.divisionsList.Cast<Lazy>().AsEnumerable<Lazy>();


This code does not give me the divisions options and I can't query my database because this divisions are not saved yet. I was trying to limit the choices of my combobox.

You can give me an idea of how can i do that?


Thanks to all.

David Frija

Jan 24, 2010 at 1:43 PM

Don't quite fully understand your problem.

 * If you want to query the database you will have to create a custom service operation.

 * If you want to place some new fat Lazyies (Lite when we release SF 2.0) is should work ok.

I need more context, who is filling divisionList ? there are lazies in there?

BTW, the AsEnumerablle<Lazy> at the end is redundant.

Tell me more and I will try to solve your problem.


Jan 25, 2010 at 2:06 PM

Hi olmo, thanks for your help.

This application is for my thesis about domotic modelation and in the previous screen I define a structure of a house { House -> Floor -> Divisions}, this house could be new or saved in DB before. So in this screen I want to define a device and I want to limit some options, I want that user only choose divisions of the house that he choose before.

So I can't query database because in some cases the house is new and yet not saved in database. So I was sending my entity house and other options (like service defined before) to this screen in the constructor and do this:

private IList divisionsList = null;

public DeviceSpecification(HomeDN homeList, IList userList, IList servicesList,
            IList supervisorsList)


            //set divisions
            this.divisionsList = new MList<DivisionDN>();
            foreach (FloorDN floor in homeList.Floors)
                foreach (DivisionDN div in floor.Divisions)



private IEnumerable<Lazy> divisions_LoadData()
            return this.divisionsList.Cast<Lazy>();

In that point, when the entity combo is loading data I can see divisions in divisionsList but in the interface doesn't appear nothing.


About your question " there are lazies in there?", I don't now, when a house is in database then yes, but when the house is created then no, the house is not saved yes. But I do not have sure about that.

My house has a MList<FloorDN> floors; and my floor have a MList<DivisionDN> divisions.

I appreciate very much your help =).

Best regards,


Jan 26, 2010 at 12:47 AM

Hi, DFrija.

If I understand your code correctly, divisionList is an untyped List with DictionaryDN entities in there. Cast<Lazy> is a Linq operator that is not goint to make any kind of smart conversion, and there's no implicit or explicit operator from Entities to Lites or the other way arround. 

Try doing 

this.divisionList.Add(div.ToLazy()) Instead. 


(personally, I will write it using a query like this:

private IEnumerable<Lazy> divisions_LoadData()
       return from floor in homeList.Floors
                 from div in floor.Division
                 select div.ToLazy() 


PD: In the SF 1.0 implementation of EntityCombo there was no way to invalidate or reload the entityCombo once is loaded. If you need such functionality you should use an standart ComboBox, hack-it some way, or wait for SF 2.0

Hope it helps, let me know if you have some problems.

Jan 26, 2010 at 10:00 PM

Thanks olmo, this resolve part of my problem, I can see options in entityCombo when the divisions are saved before, because div.ToLazy() throw the exception "ToLazyLight not allowed for new entities".

private IEnumerable<Lazy> divisions_LoadData()
            return from floor in system.HomeDefinition.Floors
                   from div in floor.Divisions
                   select (Lazy) div.ToLazy();


So I think that I have to use a standard drop box.

Thanks for your help.

Jan 28, 2010 at 5:13 PM

Try ToLazyFat instead

Jan 28, 2010 at 5:43 PM

Hello, I try that too, with ToLazyFat I can see the options but when a select one it gives me the Exceptions "Entity with type DivisionDN and Id 0 not found".

Thanks =)

Jan 29, 2010 at 10:25 AM

Ups!, you right.

In SF 1.0 this is a bug in Server.Convert.

You will have to use a standart combobox to do that, or wait till SF 2.0 in the next months.


Jan 29, 2010 at 4:39 PM

OK, I will use a standard comboBox for now because I a have a little hurry.

Thanks for your help.

; )