Lazy MList???

Jun 18, 2009 at 3:40 AM
Edited Jun 18, 2009 at 3:42 AM

I have a problem, but first sorry for my english. I have an entity Continent and a property called Continet.Countries wihc is of type MList, when I retireve the list of continents I don't wan´t to load the countries, so I need it to be lazy. How can a do that?

Thanks in advance for the help.


Jun 18, 2009 at 2:01 PM
Edited Jun 18, 2009 at 2:02 PM

Hi argons6,

We usually don't do it that way, instead we make a reference from Country to continent, so Continent is lightweight, and you force a country to be in one and only one continent.

Fron a validation pespective, I don't think a continent should be wrong when one of the countries is wrong, so this is not a problem.

If you need a UI where you see all the countries in a continent all at once you can use a SearchControl ( backed with a Linq query in the server, instead of a EntityList

  Entity = c.ToLazy(),
  Continent = c.Continent.ToLazy()

Anyway, if having a fat MList is a MUST you have two options:

1.- We don't support Lazy<MList<Country>> but we have MList<Lazy<Country>>, so you can handle your countries from the UI pretending they are there but you have just lazies (ID & ToStr)

2.- Split Continent entity in two clases, Continent and ContinentData, ContinentData have the MList<Country> and Continent has the Name and a Lazy<ContinentData>

Hope it helps, and thanks for your feedback.

Jun 18, 2009 at 5:03 PM

Thanks for the reply olmo, I'm going for option 1 and using MList<Lazy<Country>> and I have a question, How can I load all elements of the list?

I have another problem, I have an entity that will hold many many many data, so I need the Id to be bigint, not only int in the generated table, how can I do this?

Thanks in advance, and keep going with the great job (Y)


Jun 18, 2009 at 11:35 PM

Hi again Ariel,

In SF 1.0 there's no overload in Database to get all the Lazy at once, so you will have to retrieve it one by one.

By defaul every MList is mapped as a relational table, so it creates a Many to MAny relationship (as I point, nothing stops you from having the same continent in two countries, and that's why I recomended changing the direction of the reference making Country point to a Continent)

I don't see what many to many relationships has to do with bigints, but there's no way to change that. Id is an inherited member from IdentifiableEntity and there's no way to change that.

We choose Int as the PrimaryKey of every entity because we think more than rows in a table is enought for our scenarios? What are you planning to build ?

Hope it helps,


Jun 19, 2009 at 1:01 PM

Well it was just a case scenario about the bigint, but for my case it's just fine using ints :)

Thanks olmo for the help and the quick replies, as I said, keep going with the great job, I'm looking forward for the web controls.