This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
Hi I start recently to test Lightspeed for linq to Oracle. I made a simple test to see what exactly is offered by this product and when I invoke the method saveChanges() I receive a "NotImplementedException". Maybe I use the wrong way to connect to the data.
Here is the test I perform : DataModelUnitOfWork dc = new DataModelUnitOfWork();
Thanks in advance for your help,
|
|
|
The problem is that Oracle does not support the IdentityColumn identity method. IdentityColumn is intended for use with auto-increment or unique-identifier style columns, where the database itself populates the ID column when a row is inserted. Oracle doesn't have that feature. Consider setting the IdentityMethod to KeyTable or Sequence instead (these will require you to create an appropriate table or sequence in the database -- see Help Topics > Identity Generation in the help file, and the Providers > Oracle9 or Oracle9 ODP directory under the LightSpeed install directory. We have since improved this error message to give a clearer explanation of the problem. |
|
|
Hi Ivan, Thanks for the quick answer. I change the IdendityMethod by Sequence but I got again an exception "Table or views does not exist". I use oracle 10 express edition for my test maybe it's the problem. I found the script sequence.sql in the Lightspeed install directory. Which importance does it have? The sql generate for the sequence by oracle is not necessary ?
Many Thanks,
SimplyMath |
|
|
Hi SimplyMath, The error is telling you that the expected sequence does not exist in the database. With the Sequence IdentityMethod, LightSpeed tries to do a SELECT NEXT from the "LightSpeed" sequence to allocate an ID, and this of course fails if that sequence does not exist. (Similarly if you use IdentityMethod.KeyTable, that will fail if the "KeyTable" table does not exist.) You need to run the Sequence.sql file to create this sequence. You can do this via Run SQL Command Line or via the browser interface by uploading then running Sequence.sql (Home > SQL > SQL Scripts > Upload, then select the uploaded script and choose Run). Oracle 10 Express Edition should work okay -- we use it for some of our own testing -- though we have found a couple of minor differences in behaviour. |
|
|
Hi Ivan
Many thanks for the help It works finally :) Now my model is implemented but I've got an error when I get an instance of a entity during the runtime.
here is my code : DataModelUnitOfWork dc = new DataModelUnitOfWork();Mindscape.LightSpeed. LightSpeedContext c = new Mindscape.LightSpeed.LightSpeedContext();c.ConnectionString = "Data Source=localhost;Persist Security Info=True;User ID=test;Password=****";c.DataProvider = DataProvider.Oracle9; c.IdentityMethod = IdentityMethod.IdentityColumn;dc.Context = c; dc.Context.CreateUnitOfWork(); var unit = c.CreateUnitOfWork(); Pay p = new Pay(); I receive a StackOverflowException.Thanks in advance
SimplyMath
|
|
|
I'm a little bit confused. You say you get a StackOverflowException when you get an instance of an entity, but in your sample code you are just new-ing up a Pay object -- you are not retrieving it from the database, and it is not yet attached to a unit of work. This suggests there is some recursion going on inside the Pay constructor. Could you post the implementation of Pay? Could you provide a partial stack trace showing the recursion? Also, it would probably be a good idea to remove the variable dc and all references to it. It shouldn't be causing any harm, but it's not doing you any good either and it slightly obscures the core code path around c and unit (and, to be clear, that code path is correct). If you would like unit to be a DataModelUnitOfWork instead of a plain IUnitOfWork, change c to be a LightSpeedContext<DataModelUnitOfWork> -- then CreateUnitOfWork() will return a DataModelUnitOfWork for you. |
|
|
Hi Ivan
Thanks for the answer :
Here is the code of the entity Pay :
[Serializable]
[System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
[Table("PAYS", IdColumnName="PK_PAYS")]
public partial class Pay : Entity
{
#region Fields
[ValidatePresence]
[ValidateLength(0, 255)]
private string _label;
#endregion
#region Field attribute names
public const string LabelField = "Label";
#endregion
#region Relationships
private readonly EntityCollection _adresses = new EntityCollection();
#endregion
#region Properties
public EntityCollection Adresses
{
get { return Get(_adresses); }
}
public string Label
{
get { return Get(ref _label); }
set { Set(ref _label, value, "Label"); }
}
#endregion
}
and Adresse
[Serializable]
[System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")]
[Table(IdColumnName="PK_ADRESSE")]
public partial class Adresse : Entity
{
#region Fields
[Column("CODE_POSTAL")]
[ValidateLength(0, 10)]
private string _codePostal;
[ValidateLength(0, 10)]
private string _numero;
[ValidateLength(0, 255)]
private string _rue;
[ValidateLength(0, 50)]
private string _ville;
[Column("FK_PATIENT")]
private int _fkPatientId;
private int _fkPaysId;
#endregion
#region Field attribute names
public const string CodePostalField = "CodePostal";
public const string NumeroField = "Numero";
public const string RueField = "Rue";
public const string VilleField = "Ville";
public const string FkPatientIdField = "FkPatientId";
public const string FkPaysIdField = "FkPaysId";
#endregion
#region Relationships
private readonly EntityCollection _medecins = new EntityCollection();
[ReverseAssociation("Adresses")]
private readonly EntityHolder _fkPatient = new EntityHolder();
[ReverseAssociation("Adresses")]
private readonly EntityHolder _fkPays = new EntityHolder();
#endregion
#region Properties
public EntityCollection Medecins
{
get { return Get(_medecins); }
}
public Patient FkPatient
{
get { return Get(_fkPatient); }
set { Set(_fkPatient, value); }
}
public Pay FkPays
{
get { return Get(_fkPays); }
set { Set(_fkPays, value); }
}
public string CodePostal
{
get { return Get(ref _codePostal); }
set { Set(ref _codePostal, value, "CodePostal"); }
}
public string Numero
{
get { return Get(ref _numero); }
set { Set(ref _numero, value, "Numero"); }
}
public string Rue
{
get { return Get(ref _rue); }
set { Set(ref _rue, value, "Rue"); }
}
public string Ville
{
get { return Get(ref _ville); }
set { Set(ref _ville, value, "Ville"); }
}
public int FkPatientId
{
get { return Get(ref _fkPatientId); }
set { Set(ref _fkPatientId, value, "FkPatientId"); }
}
public int FkPaysId
{
get { return Get(ref _fkPaysId); }
set { Set(ref _fkPaysId, value, "FkPaysId"); }
}
#endregion
}
In my test i would like create an instance of pay and add it in DataBase.
Here is my test code :
Mindscape.LightSpeed.LightSpeedContext c = new Mindscape.LightSpeed.LightSpeedContext();
c.ConnectionString = "Data Source=localhost;Persist Security Info=True;User ID=test;Password=test";
c.DataProvider = DataProvider.Oracle9;
c.IdentityMethod = IdentityMethod.IdentityColumn;
using (var unitOfWork = c.CreateUnitOfWork())
{
Pay p = new Pay();
p.Label = "Belgique";
}
Here is my error message's :
An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll
Could you say me how I can a new instance of the database and add it to DB. I don't find the good way for using LightSpeed.
Thanks in advance.
SimplyMath
|
|
|
Normal 0 21 false false false FR-BE X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} Normal 0 21 false false false FR-BE X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin-top:0cm; mso-para-margin-right:0cm; mso-para-margin-bottom:10.0pt; mso-para-margin-left:0cm; line-height:115%; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin;} Hi Ivan Thanks for the answer Here is the code of the entity Pay : [Serializable] [System.CodeDom.Compiler.GeneratedCode("LightSpeedModelGenerator", "1.0.0.0")] [Table("PAYS", IdColumnName="PK_PAYS")] public partial class Pay : Entity<int> { #region Fields
[ValidatePresence] [ValidateLength(0, 255)] private string _label;
#endregion
#region Field attribute names
public const string LabelField = "Label";
#endregion
#region Relationships
private readonly EntityCollection<Adresse> _adresses = new EntityCollection<Adresse>();
#endregion
#region Properties
public EntityCollection<Adresse> Adresses { get { return Get(_adresses); } }
public string Label { get { return Get(ref _label); } set { Set(ref _label, value, "Label"); } }
#endregion } In my test i would like create an instance of pay and add it in DataBase. Here is my test code : Mindscape.LightSpeed.LightSpeedContext<DataModelUnitOfWork> c = new Mindscape.LightSpeed.LightSpeedContext<DataModelUnitOfWork>();c.ConnectionString = "Data Source=localhost;Persist Security Info=True;User ID=test;Password=test"; c.DataProvider = DataProvider.Oracle9; c.IdentityMethod = IdentityMethod.IdentityColumn; using (var unitOfWork = c.CreateUnitOfWork()) { Pay p = new Pay(); p.Label = "Belgique"; }
Here is my error message's : An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll Could you say me how I can a new instance of the database and add it to DB. I don't find the good way for using LightSpeed. Thanks in advance. SimplyMath |
|
|
Hello SimplyMath, Sorry for the delay in replying, and that you're seeing this problem. Unfortunately we have been unable to reproduce the StackOverflowException with the code given. I have also tried adding the Pay to the unit of work and saving it, and still no error. So I have a few more questions I'm afraid: - Which line does the exception occur on -- e.g. is it the Pay constructor, when you set the Label property, or some other line (e.g. saving changes) which is not shown? - When the StackOverflowException occurs, what are the top ten lines from the Visual Studio call stack window or the stack trace? - Have you extended the partial class with your own code? If so can you provide us with a copy of this code please? - If the exception is occurring on the Label setter, do you have any subscribers to the PropertyChanged event? Note that if you use Label in WinForms or WPF data binding this will create such a subscription. - Are you able to save other types of entity, or is the problem specific to Pay? Hopefully this will enable us to solve your problem! |
|