One-to-One or one-to-many

Feb 19, 2010 at 11:15 PM

Hello,

when i use the northwind database. Why is in the result the Orders of the Customers not filled??

 var customers = (from d in db.Customers

 where d.Phone != "0921-12 34 65" <font size="2">

 

</font>

select d).First()

Coordinator
Feb 19, 2010 at 11:25 PM

Retrieving associated data is expensive.  You have to specify which associations you want loaded by asking for them using a QueryPolicy.  The latest release, v0.17, introduces a new class EntityPolicy that is an implementation of QueryPolicy that you can use to specify which associations are loaded.  See this blog post for more details.

Feb 22, 2010 at 2:12 PM

thx that did the job!

I have question with the following problem:

public class DbKleurGroep
{
        public int id { get; set; }
        public string naam { get; set; }
}
DbContext db = new DbContext();
DbKleurGroep kleurgroep = new DbKleurGroep(){naam="test"};
db.Kleur_Groepen.SetSubmitAction(kleurgroep, IQToolkit.SubmitAction.Insert);
         
db.SubmitChanges(); 

After the DbKleurGroep is added in the database i want to that he ID is automatically is filled again. Is that possible with a property?

greetings,

 

Sander

Coordinator
Feb 22, 2010 at 11:50 PM

The EntitySession class does not currently handle resynching object state after insert/update.

Feb 23, 2010 at 2:13 PM

Well the only way to this is this way?

public virtual IUpdatable Kleur_Groepen
{
        get { return this.Provider.GetTable("kleur_groepen"); }
}

DbKleurGroep kleurgroep = new DbKleurGroep() { naam = "test" };
kleurgroep.id = db.Kleur_Groepen.Insert(kleurgroep, (c => c.id))

greetings,

Sander

Coordinator
Feb 24, 2010 at 6:16 PM

Yes, that's currently the only way to do it.