It is not applicable to many-to-one. So it just doesn't work.
It would be nice if I could do this.

2009/8/3 Tuna Toksoz <[email protected]>

> all-delete-orhpans
>
> Tuna Toksöz
> Eternal sunshine of the open source mind.
>
> http://devlicio.us/blogs/tuna_toksoz
> http://tunatoksoz.com
> http://twitter.com/tehlike
>
>
>
>
>
> On Mon, Aug 3, 2009 at 9:38 AM, Dmitiry Nagirnyak <[email protected]>wrote:
>
>> Hi,
>>
>> I have difficulty making the test below to pass. I need to tell NH that
>> there's only 1 Image related to Product and if another is assigned the old
>> one should be deleted.
>>
>> Some help please?
>>
>> // THE TEST
>> [Test]
>> public void ReplaceProductImage_DeletesOldRecord() {
>>  // Initialise
>>  var p = new Product {
>>   Image = new BinaryContent {
>>    Content = Encoding.ASCII.GetBytes("image")
>>   }
>>  };
>>  Session.Save(p);
>>  Session.Flush();
>>  // Exercise
>>  var totalImagesBefore = Session.Linq<BinaryContent>().Count();
>>  p.Image = new BinaryContent {
>>   Content = Encoding.ASCII.GetBytes("another")
>>  };
>>  Session.Flush();
>>  var totalImagesAfter = Session.Linq<BinaryContent>().Count();
>>  // Verify
>>  totalImagesAfter.Should().Be.EqualTo(totalImagesBefore);
>> }
>>
>>
>> // THE MODEL
>> public class Product {
>>  public virtual int Id { get; protected set; }
>>  public virtual BinaryContent Image { get; set; }
>> }
>> public class BinaryContent {
>>  public virtual int Id { get; protected set; }
>>  public virtual byte[] Content { get; set; }
>> }
>> // THE MAPPING
>> public class BinaryContentMap : ClassMap<BinaryContent> {
>>  public BinaryContentMap() {
>>   Id(x => x.Id).GeneratedBy.Native();
>>   Map(x => x.Content).CustomTypeIs("BinaryBlob").WithLengthOf(102400);
>>  }
>> }
>>
>>
>>
>> Cheers,
>> Dmitriy.
>>
>>
>>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to