Re: AR - issue with removing an item from a HasMany relation

2009-01-13 Thread Markus Zywitza
In one application, I associate user accounts with computers based on usage of the computer. I have to both access the computers from the accounts and vice versa in many places in my code. Therefore I took the way to make it bidirectional using Add/Remove-Methods to assure that the association is

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Markus Zywitza
Then why do have the BlogId property in there? Simply discard it. -Markus 2009/1/12 Mark Jensen don...@gmail.com: haven't tested it yet, but is it really required to make it bidirectional for this to work ? because I only need it to go one way :/ On Jan 10, 2:41 pm, Markus Zywitza

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Mark Jensen
Yep :) but if i remove the property from the object I get the above error On Jan 12, 2:04 pm, Colin Ramsay colinram...@gmail.com wrote: You need the column in the DB but you don't need the property on the post object. On Mon, Jan 12, 2009 at 12:44 PM, Mark Jensen don...@gmail.com wrote:

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Colin Ramsay
Just checking, I mean you should still have: [BelongsTo(BlogId)] public Blog Blog {get; set;} But remove: [Property(BlogId, NotNull = true)] public Guid BlogId { get; set; } On Mon, Jan 12, 2009 at 1:17 PM, Mark Jensen don...@gmail.com wrote: Yep :) but if i remove the property from the

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Mark Jensen
a :) im sure how bidirectional works in NH, but from the description you give me, it sounds like that unidirectional adds a little bit more work when is persists objects ? Even though i dont really need it to be bidirectional, would be better performance wise to go with bidirectional

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Mark Jensen
woops.. i mean... im NOT sure how NH works... On Jan 12, 2:34 pm, Markus Zywitza markus.zywi...@gmail.com wrote: Remove the not null-constraint from the database column. This is needed as NH works this way: 1) You save the parent 2) Parent cascades to newly created child 3) Child is saved

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Ben Lovell
It would be /slightly/ better performance wise but you should avoid bidirectional associations where possible. Bidirectional association is rarely necessary and usually highlights a flaw in your modelling. The performance hit isn't exactly huge anyway and unless you've measured you're making a

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Markus Zywitza
So when would you consider to use bidirectional association ? When you need to access the objects via both directions. -Markus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Castle Project Users group. To post to

Re: AR - issue with removing an item from a HasMany relation

2009-01-12 Thread Mark Jensen
haha, yeah :P but do you have an example when this could be relevant :) On Jan 12, 3:59 pm, Markus Zywitza markus.zywi...@gmail.com wrote: So when would you consider to use bidirectional association ? When you need to access the objects via both directions. -Markus

Re: AR - issue with removing an item from a HasMany relation

2009-01-09 Thread Mark Jensen
I have switched over to Guids (GuidComb) instead Now the foreignkey in Post is just guid.empty :/ when I create a new Blog and add a Post to it. On Jan 9, 1:19 pm, Markus Zywitza markus.zywi...@gmail.com wrote: Here is my setup/teardown: [SetUp] public void Setup()

Re: AR - issue with removing an item from a HasMany relation

2009-01-09 Thread Markus Zywitza
schema generation: http://www.castleproject.org/activerecord/documentation/trunk/usersguide/schemagen.html When you create a new Post, it's ID is Guid.Empty. That's just fine, as this is the unsaved value. When the post is saved and flushed, it is assigned an Guid generated by NH. -Markus

Re: AR - issue with removing an item from a HasMany relation

2009-01-09 Thread Markus Zywitza
Can you post the Post type please? 2009/1/9 Mark Jensen don...@gmail.com: Thanks, I read that... but I dont understand the Paramter in the CreateSchema() anyway...it is not the ID on Post that is the problem.. it is the BlogID on Post that is empty after I persist Blog with Blog.Save().

Re: AR - issue with removing an item from a HasMany relation

2009-01-09 Thread Mark Jensen
Sure thing :) I have removed a few things but the essential things should be there public abstract class BaseEntityT : ActiveRecordValidationBaseT where T : class { private readonly DateTime created; private DateTime modified; public BaseEntity() { created =

Re: AR - issue with removing an item from a HasMany relation

2009-01-08 Thread Markus Zywitza
Yes, I overlooked that you used Cascade = ManyRelationCascadeEnum.SaveUpdate That must be Cascade = ManyRelationCascadeEnum.AllDeleteOrphan to automatically delete posts. -Markus 2009/1/8 Mark Jensen don...@gmail.com: Hi Markus the Inverse = true, doesn't seem to do anything, the changes

Re: AR - issue with removing an item from a HasMany relation

2009-01-08 Thread Markus Zywitza
Do you use MSSQL Identity for your PKs? -Markus 2009/1/8 Mark Jensen don...@gmail.com: BTW. when I Add a new Post the BlogID is zero when I persist this way Blog.Save(); On Jan 8, 3:18 pm, Markus Zywitza markus.zywi...@gmail.com wrote: 2009/1/8 Mark Jensen don...@gmail.com:

Re: AR - issue with removing an item from a HasMany relation

2009-01-08 Thread Mark Jensen
Atm, yes I haven't really dicided if I shoud go with Identity og Guids I have choosen Identity so fare, because i believe it to be faster.. On Jan 8, 3:46 pm, Markus Zywitza markus.zywi...@gmail.com wrote: Do you use MSSQL Identity for your PKs? -Markus 2009/1/8 Mark Jensen

Re: AR - issue with removing an item from a HasMany relation

2009-01-08 Thread Mark Jensen
When I switch my primarykeys on Blog and Post to HiLo I get the following error System.Data.SqlClient.SqlException: Invalid object name 'hibernate_unique_key'. On Jan 8, 3:51 pm, Markus Zywitza markus.zywi...@gmail.com wrote: GuidComb is nearly as fast as Identity. With AR/NH its even faster

Re: AR - issue with removing an item from a HasMany relation

2009-01-08 Thread Markus Zywitza
You have to recreate the schema. It creates a table to store the next hi to use. 2009/1/8 Mark Jensen don...@gmail.com: When I switch my primarykeys on Blog and Post to HiLo I get the following error System.Data.SqlClient.SqlException: Invalid object name 'hibernate_unique_key'. On Jan

Re: AR - issue with removing an item from a HasMany relation

2009-01-08 Thread Mark Jensen
recreate? how Atm I running the thing in a unittest where I do the following XmlConfigurationSource source = new XmlConfigurationSource(../../ AppConfig.xml); Assembly asm = Assembly.Load(myDomain); ActiveRecordStarter.Initialize(asm, source); On Jan 8, 4:10 pm, Markus Zywitza

Re: AR - issue with removing an item from a HasMany relation

2009-01-08 Thread Markus Zywitza
ActiveRecordStarter.CreateSchema(); ActiveRecordStarter.DropSchema(); ActiveRecordStarter.UpdateSchema(); 2009/1/8 Mark Jensen don...@gmail.com: recreate? how Atm I running the thing in a unittest where I do the following XmlConfigurationSource source = new XmlConfigurationSource(../../