How to Create index on component property

12 views
Skip to first unread message

Haimon

unread,
Jul 8, 2013, 8:27:39 AM7/8/13
to nhu...@googlegroups.com

I have the following classes:

public class Event
{
    public virtual Guid Id { get; set; }
    public virtual string UserName { get; set; }
    public virtual EventId EventId { get; set; }
}

public class EventId 
{
    public virtual Guid EventGuid {get; private set;}
}

I am using a fluent NHibernate automapping in order to map my classes and I override specific properties when needed.

Class: Event is in s_typesToMap and class: EventId is in s_components.

As a result I get the following table generated:

create table "Event" (
   Id UNIQUEIDENTIFIER not null,
   UserName NVARCHAR(255) null,
   EventIdentifierEventGuid UNIQUEIDENTIFIER null,
   primary key (Id)
)

I want to create an index on EventIdentifierEventGuid which is a property in Event component.

I tried to do it as follows:

.Override<Event>(obj => obj.Map(x => x.EventId.EventGuid).Index("EventId_index"))

When I generate the ddl I get the following:

create index EventId_index on "Event" (EventGuid)

The expected result should be an index on EventIdentifierEventGuid instead of EventGuid

How can I do it?

Haimon

unread,
Jul 9, 2013, 4:04:12 AM7/9/13
to nhu...@googlegroups.com
Really needs your help. anyone???

Ricardo Peres

unread,
Jul 9, 2013, 8:50:01 AM7/9/13
to nhu...@googlegroups.com
See Fabio Maulo's post here http://fabiomaulo.blogspot.co.uk/2011/07/nhibernate-playing-with-mapping-by-code.html, specifically the part on auxiliary database objects and see if it helps.

RP

Haim Rozenblum

unread,
Jul 9, 2013, 9:36:43 AM7/9/13
to nhu...@googlegroups.com

Thanks a lot for your reply – I will try your solution now and let you and the group know about it

--
You received this message because you are subscribed to a topic in the Google Groups "nhusers" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/nhusers/YL2Fnkg0Sg8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to nhusers+u...@googlegroups.com.
To post to this group, send email to nhu...@googlegroups.com.
Visit this group at http://groups.google.com/group/nhusers.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages