This question is locked. New answers and comments are not allowed.
RICHARD FRIEND
Top achievements
Rank 2
RICHARD FRIEND
asked on 02 Jul 2009, 09:52 AM
Hi
I have an entity of Company that has a property of ParentCompanyId.
When i reverse map this and add the relationship i get
Company.ParentCompany
but i would like to keep
Company.ParentCompanyId
to save me having to load the company object just to get id, is this possible?
I have an entity of Company that has a property of ParentCompanyId.
When i reverse map this and add the relationship i get
Company.ParentCompany
but i would like to keep
Company.ParentCompanyId
to save me having to load the company object just to get id, is this possible?
5 Answers, 1 is accepted
0
RICHARD FRIEND
Top achievements
Rank 2
answered on 02 Jul 2009, 09:59 AM
Also
I have a RowVersion(int) in all my tables, i wish to use this as my concurrency version field, however i also want to display this on my app, openaccess removes the property from my class when i set it to version, any way to prevent this ?
I have a RowVersion(int) in all my tables, i wish to use this as my concurrency version field, however i also want to display this on my app, openaccess removes the property from my class when i set it to version, any way to prevent this ?
0
Hello Richard,
Yes, this is possible. Just delete the reference from the Reverse mapping wizard, the ID property will be generated instead. Note that if you have already generated a partial class for this table, its relevant .cs file will not be changed in order to keep any changes you might have made there. You can find the new code in a commented block at the bottom of the .Telerik.OpenAccess.cs file and just copy it to the actual .cs file.
Regarding the second question, I do not think this should be done. When you set the field to 'version', it is marked to be handled internally and if you expose it in the class, this may lead to insert / update problems. We already had a similar issue with a discriminator column in this thread. Read was fine, but the Inserts were failing.
Greetings,
Alexander
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Yes, this is possible. Just delete the reference from the Reverse mapping wizard, the ID property will be generated instead. Note that if you have already generated a partial class for this table, its relevant .cs file will not be changed in order to keep any changes you might have made there. You can find the new code in a commented block at the bottom of the .Telerik.OpenAccess.cs file and just copy it to the actual .cs file.
Regarding the second question, I do not think this should be done. When you set the field to 'version', it is marked to be handled internally and if you expose it in the class, this may lead to insert / update problems. We already had a similar issue with a discriminator column in this thread. Read was fine, but the Inserts were failing.
Greetings,
Alexander
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
RICHARD FRIEND
Top achievements
Rank 2
answered on 06 Jul 2009, 09:51 AM
Hi
In regards to my second question, i know i shouldnt be mapping this however i just want to get the value, if this is from a helper method or using the API thats fine, i dont see the point in having to add another field to my database and keep in sync with my current version field just so i display this...
In regards to my second question, i know i shouldnt be mapping this however i just want to get the value, if this is from a helper method or using the API thats fine, i dont see the point in having to add another field to my database and keep in sync with my current version field just so i display this...
0
RICHARD FRIEND
Top achievements
Rank 2
answered on 06 Jul 2009, 11:32 AM
Never mind, got it.
I added the following to the template file.
public int internalRowVersion
{
get
{
string ver;
string key = Telerik.OpenAccess.DataObjectKey.Obtain(this);
Telerik.OpenAccess.DataObjectKey.Interpret(key, out ver);
return int.Parse(ver);
}
}
I added the following to the template file.
public int internalRowVersion
{
get
{
string ver;
string key = Telerik.OpenAccess.DataObjectKey.Obtain(this);
Telerik.OpenAccess.DataObjectKey.Interpret(key, out ver);
return int.Parse(ver);
}
}
0
Hello Richard,
I am glad you found a solution, it is very elegant indeed. I initially thought you want to map the field directly.
Best wishes,
Alexander
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I am glad you found a solution, it is very elegant indeed. I initially thought you want to map the field directly.
Best wishes,
Alexander
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.