Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Handling Identities
Message
From
15/03/2010 13:36:22
 
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
01454212
Message ID:
01454611
Views:
30
I definitely regenerated everything for the BO. Unfortunately I don't have any other identity fields in my database.

This is really just a mental exercise, trying to help me understand the framework better. What I would really like to achieve is display a field on the form (web page) that shows the Agent Number, but also lets the user enter the number. When a new agent is added, if the user leaves that field blank, I would like to generate the next continuous number available, but yet they can use their own numbering scheme if desired by manually entering the values.

I see there is an AutoIncrementCustom property, but this seems to only work on PKs and I can't find a way to tell it to use a particular column.

>Hi Frank,
>
>You shouldn't have to do anything for this. The problem (I believe) was not with the Set method but with the fact that you were attempting to explicitly save the identity column value in your data layer. I believe if you regenerate the object again (and be sure to regenerate the data access layer and redefine stored procedures) you will not have this problem.
>
>To confirm this, check any other business objects you have that has an identity column. You will see that the properties for the identity column (in the Entity object) are as you have listed previously for your agent number.
>
>Bob
>
>>Hi Bob,
>>
>>I have actually manually adjusted the code generated by the generator (I commented out the Set method on the entity and removed references to the field in the data access) and adjusted the stored procedures accordingly. This fixes the problem, until next time I generate. How do I fix this once and for all so that the generator does not generate this code?
>>
>>>Frank,
>>>
>>>Check your Insert stored procedure (or SQL statement depending on what you use) for inserting into your base table and be sure you do not have a value that is passed in for this identity column. If you didn't regenerate the data access layer using the BLG, you would have a problem with this.
>>>
>>>
>>>Bob
>>>
>>>>Hi,
>>>>
>>>>I have changed a varchar column to a smallint identity column, regenerated using the Business Layer Generator, but when I run my application I get this error:
>>>>
>>>>Column 'AgentNumber' is read only.
>>>>
>>>>in my AgentEntity class on this code:
>>>>
>>>>
>>>>		public Int16 AgentNumber
>>>>		{
>>>>			get
>>>>			{
>>>>				if (this.Row != null)
>>>>					return (Int16)mmType.GetNonNullableDbValue(this.Row["AgentNumber"], "System.Int16");
>>>>				else
>>>>					return this._agentNumber;
>>>>			}
>>>>			set
>>>>			{
>>>>				if (this.Row != null)
>>>>					this.Row["AgentNumber"] = value; 
>>>>				this._agentNumber = value;
>>>>				this.OnPropertyChanged(new PropertyChangedEventArgs("AgentNumber"));
>>>>			}
>>>>		}
>>>>		private Int16 _agentNumber;
>>>>
>>>>The error occurs on this.Row["AgentNumber"] = value;
>>>>
>>>>What have I done wrong/missed out here?
>>>>.
Frank.

Frank Cazabon
Samaan Systems Ltd.
www.samaansystems.com
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform