Entitity Framework, problem with lazy loading
Posted by: John Bradshaw
Date: April 24, 2009 01:36PM

I have a fairly simple Entity Framework test set up like so...

var result = from p in database.DnsDomainsSet select p;

foreach (DnsDomains item in result)
{
    if (!item.DnsRecords.IsLoaded)
    {
        item.DnsRecords.Load();
    }

    foreach (DnsRecords record in item.DnsRecords)
    {
        string a = record.name;
    }
}

What happens is I this exception on the line item.DnsRecords.Load()

[ArgumentOutOfRangeException: The specified parameter type 'System.UInt32' is not valid. Only scalar types, such as System.Int32, System.Decimal, System.DateTime, and System.Guid, are supported.
Parameter name: parameter]

   System.Data.Objects.ObjectParameterCollection.Add(ObjectParameter parameter) +2954906
   System.Data.Objects.DataClasses.RelatedEnd.CreateSourceQuery(MergeOption mergeOption) +1456
   System.Data.Objects.DataClasses.RelatedEnd.ValidateLoad(MergeOption mergeOption, String relatedEndName) +49
   System.Data.Objects.DataClasses.EntityCollection`1.Load(IEnumerable`1 collection, MergeOption mergeOption) +94
   System.Data.Objects.DataClasses.EntityCollection`1.Load(MergeOption mergeOption) +20
Does anyone have any ideas? If i use..

var result = from p in database.DnsDomainsSet.Include("DnsRecords") select p;

instead of using the .Load() method everything works fine.

Cheers,
John

Options: ReplyQuote


Subject
Written By
Posted
Entitity Framework, problem with lazy loading
April 24, 2009 01:36PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.