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
|
I followed the tutorial on creating my entity class manually instead of through the designer. My class looks like this:
Then I manually created a UnityOfWork class like so:
Now, when I try to persist an item to the database, I get System.Data.SqlClient.SqlException was caught
Message="Incorrect syntax near '<'."
Source=".Net SqlClient Data Provider"
ErrorCode=-2146232060
Class=15
LineNumber=3
Number=102
Procedure=""
Server="NJISINSPIRON\SQLEXPRESS"
State=1
StackTrace:
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteScalar()
at ...()
at ..(IUnitOfWork , IDbCommand , )
at ..(IUnitOfWork , IDbCommand )
at ..(Entity , )
at ..(Entity , ICollection What did I miss? Thanks in advance. |
|
|
Hi, The issue is in this line:
You cannot use automatic properties. The C# compiler will generate a backing field for this at compile time and then because LightSpeed thinks all fields are properties in your table, it tries to select that field back (and it infers the type from the type of the automatically generated property, which is typically a generic, hence the < character appearing in your query which is not valid. To fix this, change to:
If the field "_link" is not in the database and shouldn't be selected or persisted by LightSpeed, place the Transient attribute on the field:
I hope that helps! John-Daniel |
|
|
Thank you, that was it. |
|