Did you ever solve this?

Op donderdag 10 maart 2011 03:42:17 UTC+1 schreef biaachmonkie:
>
> I was looking to update a project from AR v1.0.3.0 and get use the new 
> Linq features, but I'm stuck on this error both using 
> ActiveRecordLinq.AsQueryable<ArTest>() and inheriting from 
> ActiveRecordLinqBase. If I comment out the HasMany relationship I can 
> save with the Linq Version. 
>
> Here is the code... 
>
>
> using System; 
> using System.Collections.Generic; 
> using System.Linq; 
> using System.Text; 
>
> using Castle.ActiveRecord; 
> using Castle.ActiveRecord.Framework; 
> using Castle.ActiveRecord.Framework.Config; 
> using System.Reflection; 
>
> namespace ActiveRecordTestConsoleApp 
> { 
>     class Program 
>     { 
>         static void Main(string[] args) 
>         { 
>             Castle.ActiveRecord.Framework.IConfigurationSource config; 
>             Dictionary<string, string> properties = new 
> Dictionary<string, string>(); 
>             properties.Add("connection.driver_class", 
> "NHibernate.Driver.SqlClientDriver"); 
>             properties.Add("dialect", 
> "NHibernate.Dialect.MsSql2005Dialect"); 
>             properties.Add("connection.provider", 
> "NHibernate.Connection.DriverConnectionProvider"); 
>             properties.Add("proxyfactory.factory_class", 
> "NHibernate.ByteCode.Castle.ProxyFactoryFactory, 
> NHibernate.ByteCode.Castle"); 
>             properties.Add("connection.connection_string", 
> "constring"); 
>             properties.Add("connection.isolation", 
> System.Data.IsolationLevel.ReadUncommitted.ToString()); 
>             properties.Add("command_timeout", "320"); 
>             InPlaceConfigurationSource inPlaceConfig = new 
> InPlaceConfigurationSource(); 
>             inPlaceConfig.Add(typeof(ActiveRecordBase), properties); 
>             config = inPlaceConfig; 
>             // load the assemblies to scan for ActiveRecord classes. 
>             Assembly asm = 
> Assembly.Load("ActiveRecordTestConsoleApp"); 
>             ActiveRecordStarter.Initialize(asm, config); 
>
>             var artest1 = ArTest.Find(49); 
>             artest1.Save(); // works fine 
>             var artest2 = 
> ActiveRecordLinq.AsQueryable<ArTest>().First(ar => ar.Id == 49); 
>             artest2.Save(); // exception: Illegal attempt to associate 
> a collection with two open sessions 
>
>         } 
>     } 
>
>
>     [ActiveRecord(Table = "temp.dbo.artest")] 
>     public class ArTest : ActiveRecordBase<ArTest> 
>     { 
>         [HasMany(typeof(ArTestChild), Lazy = false, Table = 
> "temp.dbo.artestchild", Inverse = true, ColumnKey = "artestid", 
> RelationType = RelationType.Bag, Cascade = 
> ManyRelationCascadeEnum.AllDeleteOrphan)] 
>         public IList<ArTestChild> ArTestChildren { get; set; } 
>
>         [PrimaryKey] 
>         public int Id { get; set; } 
>
>         [Property] 
>         public string Value { get; set; } 
>
>     } 
>
>     [ActiveRecord(Table = "temp.dbo.artestchild")] 
>     public class ArTestChild : ActiveRecordBase<ArTestChild> 
>     { 
>         [BelongsTo(Column = "artestid")] 
>         public ArTest ArTestParent { get; set; } 
>
>         [PrimaryKey] 
>         public int Id { get; set; } 
>
>         [Property] 
>         public string ChildValue { get; set; } 
>     } 
> } 
>

-- 
You received this message because you are subscribed to the Google Groups 
"Castle Project Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/castle-project-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to