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
|
Hello. Using LightSpeed version 4.0, when I try to cast the results of a LINQ query to a list or an array, I get a MySQLException run-time error: "Unknown column 't0.Id' in 'field list'". The LINQ query and casting is as follows: Dim programResults = From programs In unitOfWork.Fpxmstps Select programs.Facid, programs.Prgacr, programs.Padsc.Trim() Dim resultsAsArray As System.Array = queryResults.ToArray() 'error is thrown here In the MySQL database, there is no field called t0.Id. In the lsmodel, there isn't a field called t0.Id either. I'm not sure where this bug is occurring; LightSpeed, MySQL or LINQ. I can query on other tables in this database and cast to an array without any issues. Thanks |
|
|
UPDATE: I narrowed this down to a problem to joins and a nested queries. The results from the LINQ query is casted to an enumerable list of a custom QueryResults class, which also contains a list of another custom class of Programs. The query: Dim queryResults As IEnumerable(Of QueryResult) = From facilities In unitOfWork.Facmstps Select New QueryResult() With {.facName = facilities.Facnam.Trim, .FacID = facilities.Facid, .Programs = (From p In unitOfWork.Fpxmstps Where p.Facid = facilities.Facid Select New Program() With {.ProgramAcronym = p.Prgacr}).ToList()} The MySQLException is: Unknown column 'Facmstp.Id' in 'field list' A field of 'Id" does not exits in the Facmstp table, nor in the lightSpeed model, so I'm not sure where and how this column is getting added to the query. When I try a join, then I get an error of "Unknown column 't0.Id' in 'field list'". 'Dim queryResults As IEnumerable(Of QueryResult) = From facilities In unitOfWork.Facmstps ' Join programs In unitOfWork.Fpxmstps On facilities.Facid Equals programs.Facid ' Select New QueryResult() With {.facName = facilities.Facnam.Trim, .FacID = facilities.Facid, .Programs = New Program() With {.ProgramAcronym = facilities.Facnam}} Anyone know why these non-existent fields are getting added to the query? |
|
|
Ok, I fixed my own problem :) After adding the KeyTable and the Id field to the tables in the database, the queries started working properly. Great product by the way, very awesome! |
|