Re: [nhusers] Fluent nHibernate Composite Key of Entities/Beans/Domains

2020-09-29 Thread Ezequiel De Luca
thanks a lot, It works

El Sunday, September 27, 2020 a la(s) 6:57:24 PM UTC-3, haz...@gmail.com 
escribió:

> You need to use KeyReference instead of KeyProperty. Then it should work.
>
> On Sun, Sep 27, 2020 at 9:11 PM Ezequiel De Luca  
> wrote:
>
>> Hi:
>> I am trying to map an object which ID is composed of two Foreign Keys. 
>> Below is the Database Scripts
>> CREATE TABLE tbl_requests
>> (
>>  strID uniqueidentifier NOT NULL,
>>  …..
>>  CONSTRAINT pk_request PRIMARY KEY (strID),
>>  )
>> CREATE TABLE tbl_resources
>> (
>>  strCode uniqueidentifier NOT NULL default NEWID(),
>>  …..
>>  CONSTRAINT pk_resources PRIMARY KEY (strCode)
>> )
>> CREATE TABLE tbl_exceptions
>> (
>>  strRequest uniqueidentifier NOT NULL,
>>  strResource uniqueidentifier NOT NULL
>>  CONSTRAINT pk_exception PRIMARY KEY (strRequest, strResource),
>>  CONSTRAINT fk_resourcerequests FOREIGN KEY (strRequest) REFERENCES 
>> tbl_requests(strID),
>>  CONSTRAINT fk_resources FOREIGN KEY (strResource) REFERENCES 
>> tbl_resources(strCode)
>> )
>> The Entity/Bean/Domain that I created looks like follows:
>> public class ExceptionEntity
>> {
>>  public virtual RequestEntity objRequest { get; set; }
>>  public virtual ResourceEntity objResource { get; set; }
>> }
>> I am having a hard time trying to create the Mapping, so far what I found 
>> online were examples of composite key with string properties, but nothing 
>> with keys of objects. I was attempting the following,
>> public ExceptionMap()
>> {
>>  Table("tbl_exceptions");
>>  CompositeId()
>>   .KeyProperty(x => x.objRequest, "strRequest")
>>   .KeyProperty(x => x.objResource, "strResource");
>> }
>> but I got this exception:
>>
>> MappingException: Could not determine type for: 
>> Project.entities.RequestEntity, Project, Version=1.0.0.0, Culture=neutral, 
>> PublicKeyToken=null, for columns: NHibernate.Mapping.Column(strRequest)
>> If I replace key properties with the full path of the Ids ex: 
>> .KeyProperty(x => x.objRequest.strID, "strRequest") I get an error that the 
>> get method is not defined. Is there any way to achieve this? Should I set 4 
>> properties on my entity 2 string for the keys and 2 objects and make the 
>> KeyProperty to the strings and References to the Objects?
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "nhusers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to nhusers+u...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/nhusers/70194a7a-d950-4f66-8155-e743d9d35baen%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nhusers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nhusers/095a2631-98dd-42c1-8553-a0422ea21f2fn%40googlegroups.com.


Re: [nhusers] Fluent nHibernate Composite Key of Entities/Beans/Domains

2020-09-27 Thread madhusudhan rao
You need to create entitiy classes for every table you are using.


On Mon, Sep 28, 2020, 3:27 AM Alexander Zaytsev  wrote:

> You need to use KeyReference instead of KeyProperty. Then it should work.
>
> On Sun, Sep 27, 2020 at 9:11 PM Ezequiel De Luca 
> wrote:
>
>> Hi:
>> I am trying to map an object which ID is composed of two Foreign Keys.
>> Below is the Database Scripts
>> CREATE TABLE tbl_requests
>> (
>>  strID uniqueidentifier NOT NULL,
>>  …..
>>  CONSTRAINT pk_request PRIMARY KEY (strID),
>>  )
>> CREATE TABLE tbl_resources
>> (
>>  strCode uniqueidentifier NOT NULL default NEWID(),
>>  …..
>>  CONSTRAINT pk_resources PRIMARY KEY (strCode)
>> )
>> CREATE TABLE tbl_exceptions
>> (
>>  strRequest uniqueidentifier NOT NULL,
>>  strResource uniqueidentifier NOT NULL
>>  CONSTRAINT pk_exception PRIMARY KEY (strRequest, strResource),
>>  CONSTRAINT fk_resourcerequests FOREIGN KEY (strRequest) REFERENCES
>> tbl_requests(strID),
>>  CONSTRAINT fk_resources FOREIGN KEY (strResource) REFERENCES
>> tbl_resources(strCode)
>> )
>> The Entity/Bean/Domain that I created looks like follows:
>> public class ExceptionEntity
>> {
>>  public virtual RequestEntity objRequest { get; set; }
>>  public virtual ResourceEntity objResource { get; set; }
>> }
>> I am having a hard time trying to create the Mapping, so far what I found
>> online were examples of composite key with string properties, but nothing
>> with keys of objects. I was attempting the following,
>> public ExceptionMap()
>> {
>>  Table("tbl_exceptions");
>>  CompositeId()
>>   .KeyProperty(x => x.objRequest, "strRequest")
>>   .KeyProperty(x => x.objResource, "strResource");
>> }
>> but I got this exception:
>>
>> MappingException: Could not determine type for:
>> Project.entities.RequestEntity, Project, Version=1.0.0.0, Culture=neutral,
>> PublicKeyToken=null, for columns: NHibernate.Mapping.Column(strRequest)
>> If I replace key properties with the full path of the Ids ex:
>> .KeyProperty(x => x.objRequest.strID, "strRequest") I get an error that the
>> get method is not defined. Is there any way to achieve this? Should I set 4
>> properties on my entity 2 string for the keys and 2 objects and make the
>> KeyProperty to the strings and References to the Objects?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "nhusers" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to nhusers+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/nhusers/70194a7a-d950-4f66-8155-e743d9d35baen%40googlegroups.com
>> 
>> .
>>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nhusers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nhusers/CAMKuk26uaLS8Don3bzESSMEjV9D2UUcLnf3%2Bjj6_sAWe%3D65O%3Dg%40mail.gmail.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nhusers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nhusers/CAEs09mS%3DEMmTgJGWV5i93%3DOeOYAsj%2Bzsx2TAUXE3CeEGaoeaSQ%40mail.gmail.com.


Re: [nhusers] Fluent nHibernate Composite Key of Entities/Beans/Domains

2020-09-27 Thread Alexander Zaytsev
You need to use KeyReference instead of KeyProperty. Then it should work.

On Sun, Sep 27, 2020 at 9:11 PM Ezequiel De Luca 
wrote:

> Hi:
> I am trying to map an object which ID is composed of two Foreign Keys.
> Below is the Database Scripts
> CREATE TABLE tbl_requests
> (
>  strID uniqueidentifier NOT NULL,
>  …..
>  CONSTRAINT pk_request PRIMARY KEY (strID),
>  )
> CREATE TABLE tbl_resources
> (
>  strCode uniqueidentifier NOT NULL default NEWID(),
>  …..
>  CONSTRAINT pk_resources PRIMARY KEY (strCode)
> )
> CREATE TABLE tbl_exceptions
> (
>  strRequest uniqueidentifier NOT NULL,
>  strResource uniqueidentifier NOT NULL
>  CONSTRAINT pk_exception PRIMARY KEY (strRequest, strResource),
>  CONSTRAINT fk_resourcerequests FOREIGN KEY (strRequest) REFERENCES
> tbl_requests(strID),
>  CONSTRAINT fk_resources FOREIGN KEY (strResource) REFERENCES
> tbl_resources(strCode)
> )
> The Entity/Bean/Domain that I created looks like follows:
> public class ExceptionEntity
> {
>  public virtual RequestEntity objRequest { get; set; }
>  public virtual ResourceEntity objResource { get; set; }
> }
> I am having a hard time trying to create the Mapping, so far what I found
> online were examples of composite key with string properties, but nothing
> with keys of objects. I was attempting the following,
> public ExceptionMap()
> {
>  Table("tbl_exceptions");
>  CompositeId()
>   .KeyProperty(x => x.objRequest, "strRequest")
>   .KeyProperty(x => x.objResource, "strResource");
> }
> but I got this exception:
>
> MappingException: Could not determine type for:
> Project.entities.RequestEntity, Project, Version=1.0.0.0, Culture=neutral,
> PublicKeyToken=null, for columns: NHibernate.Mapping.Column(strRequest)
> If I replace key properties with the full path of the Ids ex:
> .KeyProperty(x => x.objRequest.strID, "strRequest") I get an error that the
> get method is not defined. Is there any way to achieve this? Should I set 4
> properties on my entity 2 string for the keys and 2 objects and make the
> KeyProperty to the strings and References to the Objects?
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nhusers+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/nhusers/70194a7a-d950-4f66-8155-e743d9d35baen%40googlegroups.com
> 
> .
>

-- 
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to nhusers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nhusers/CAMKuk26uaLS8Don3bzESSMEjV9D2UUcLnf3%2Bjj6_sAWe%3D65O%3Dg%40mail.gmail.com.