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 have another frustrating problem with the trial version of Lightspeed. Executing a Find() against one of my tables (with no criteria) always returns zero results. However, this is incorrect - there is one row in the table. I've logged the query that is generated and executed it manually in the MySQL command line and the row is returned correctly. Executing a Find() with no criteria against some other tables works fine, results are returned. What could be going wrong with the one table? I've looked at the mappings that are generated, and the only thing that looks strange is that there is one bool column in the table, and it's being mapped to an sbyte. Changing that property to a bool compiles, but the results still don't come through. The only other notable item about this table is that it has multiple foreign keys referencing the same table. It has 8 columns that all map to the "Items" table. When I placed it on the design surface, all the foreign key properties were named the same and I had to go through and rename them. In my test data, all the 8 columns are null though.
Any ideas? |
|
|
That's very strange: you should either get an entity for each row, or an exception. Could you send us a sample project that demonstrates the problem? We would need: * A project (e.g. console application) containing the model and the Find code that reproduces the error You can attach a zip file via the Options tab, or email it to ivan @ the obvious domain name (please strip all binaries first). Thanks for your help in tracking this down! |
|
|
ivan, Thanks for your reply. I discovered several interesting things as I tried to reproduce the behavior I described above in a new test project. I've been working on this issue for quite a while and I'm sorry to say I cannot reproduce it consistently, but my hunch is that it has more to do with the MySQL server than with Lightspeed. I can manage to get MySQL into a seemingly unstable state with multiple runs of my create script. Everything *seems* to be ok, but the Lightspeed context seems to be given an older version of the table than is currently in MySQL.... and the only thing that tells me that MySQL is the problem is that when this is occuring, I can't re-run my create script, because MySQL complains that my indexes already exist, even though I just dropped the database. At that point, rebooting the MySQL instance solves everything. Hence, I don't think it's actually Lightspeed's fault that the result is coming out as empty as I described earlier. However... I do have two problems with Lightspeed still. The first is that it's mapping my BOOLEAN column (which actually is implemented as a TINYINT(1) in my create script) to an "sbyte"... which produces an error when I try to fetch data with the context. "Object of type 'System.Boolean' cannot be converted to type 'System.SByte'.
If I manually change the generated code to be a bool instead of an sbyte, it's no problem. This isn't a big deal, except that every time I do an 'Update from source...', it sets it back to an sbyte...
The second issue is that I have a CHAR(1) column, which seems to map properly to a "char" value type. However, when I attempt to fetch data from the table with the CHAR column, I get the following exception, {"Unable to materialize field [...] on type [.....]. Check your table has an Id column and that your mappings are correct. See inner exception for details. "} And the Inner Exception is "Specified cast is not valid". The overall stack trace is:
" at Mindscape.LightSpeed.LightSpeedException.(Exception , String , Object[] )\r\n at Mindscape.LightSpeed.Model.FieldModel.Materialize( , Object , Object[] , Int32& )\r\n at \b.\a.(String , Entity , Object[] )\r\n at \b.\a.(TypeModel , QueryExpression , Order , String , Boolean , Boolean )\r\n at ..(TypeModel , QueryExpression , Order , String , Boolean , Boolean )\r\n at \b.\a.(TypeModel , IList , String , Boolean )\r\n at \b.\a.(TypeModel , Query , IList )\r\n at \b.\a.(UnitOfWork , TypeModel , Query , IList )\r\n at .\b.(Query , TypeModel , IList )\r\n at .\b.(Query , IList )\r\n at Mindscape.LightSpeed.UnitOfWork.Find(Query query, IList results)\r\n at Mindscape.LightSpeed.UnitOfWorkBase.Find[TEntity](Query query)\r\n at Mindscape.LightSpeed.UnitOfWorkBase.Find[TEntity](QueryExpression queryExpression, Order order, Page page)\r\n at Mindscape.LightSpeed.UnitOfWorkBase.Find[TEntity]()\r\n at MyProject.Controllers.AnimalsController.Details(Int32 id) in C:\\Documents and Settings\\User\\My Documents\\Dev\\MyProject\\MyProject\\Controllers\\AnimalsController.cs:line 39\r\n at lambda_method(ExecutionScope , ControllerBase , Object[] )\r\n at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)\r\n at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)\r\n at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)\r\n at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClassa.<InvokeActionMethodWithFilters>b__7()\r\n at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)"
Thanks for your consideration on these two new items... |
|