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
|
(This is a followup to the question found here - I did download the latest nightly builds and, in most cases, was able to successfully use FirstOrDefault()) This is extremely confusing: using the same model from the previous question, attempting to run the following query from osl in unitOfWork.OcalaStructureLookups where osl.Id.WorkLocationNumber == workLocationNumber && osl.Id.WorkRequestName == workRequestName select osl.PoleNumber with either First() or .ToList().First() will fail with the above exception, but only when the value of WORK_LOCATION_NUMBER is more than 9. Othewrise it works as expected. There is definitely a value availabe (the call .Any() passes), and even trying .FirstOrDefault() fails with the same exception. What could be causing this? The .lsmodel is as follows ----------------------------------------
<?xml version="1.0" encoding="utf-8"?> <model xmlns:dm0="http://schemas.microsoft.com/VisualStudio/2008/DslTools/Core" dslVersion="1.1.0.0" name="OcalaTelventModel" targetNamespace="Cogsdale.ConstructionManagement.Integration.Telvent.Ocala" databaseProvider="Oracle9" connectionString="Data Source=designerdev.ocalafl.org:1521/dsnupg;User Id=process;Password=pr0cessdev;" pluralizedInDatabase="false" mediumTrustCompatibility="false" xmlns="http://namespaces.mindscape.co.nz/lightspeed"> <entities> <entity name="OcalaStructureLookup" identityType="Int32" cacheExpiry="0" tableName="OCALA_STRUCTURE_LOOKUP" schema="PROCESS"> <entityProperties> <entityProperty name="PoleNumber" isNullable="true" columnName="POLE_NUMBER"> <validations> <lengthValidation minimumLength="0" maximumLength="10" /> </validations> </entityProperty> </entityProperties> <keys> <identityProperty name="WorkRequestName" columnName="WORK_REQUEST_NAME"> <validations> <lengthValidation minimumLength="0" maximumLength="10" /> </validations> </identityProperty> <identityProperty name="WorkLocationNumber" isNullable="true" columnName="WORK_LOCATION_NUMBER"> <validations> <lengthValidation minimumLength="0" maximumLength="20" /> </validations> </identityProperty> </keys> </entity> </entities> </model> -------------------------- The column definitions are WORK_REQUEST_NAME, VARCHAR2 (10 Byte), Non-Nullable WORK_LOCATION_NUMBER, VARCHAR2 (20 Byte), Nullable POLE_NUMBER, VARCHAR2 (10 Byte), Nullable --------------------------- Here is the output SQL from calling .Any() followed by .ToList(). I can't see the difference between passing in a parameter of '9' and '10', yet the latter always fails.
SELECT COUNT(*) FROM PROCESS.OCALA_STRUCTURE_LOOKUP WHERE (OCALA_STRUCTURE_LOOKUP.WORK_LOCATION_NUMBER = '9' AND OCALA_STRUCTURE_LOOKUP.WORK_REQUEST_NAME = 'EY10-119')
--> Parameter Direction DbType Value --> --------- --------- ---------- ----- --> :p0 Input String 9 --> :p1 Input String EY10-119
--> Time: 58 ms --> Result: 1
BEGIN
OPEN :cur1 FOR SELECT OCALA_STRUCTURE_LOOKUP.POLE_NUMBER AS "pole_num_0" FROM PROCESS.OCALA_STRUCTURE_LOOKUP WHERE (OCALA_STRUCTURE_LOOKUP.WORK_LOCATION_NUMBER = '9' AND OCALA_STRUCTURE_LOOKUP.WORK_REQUEST_NAME = 'EY10-119');
END;
--> Parameter Direction DbType Value --> --------- --------- ---------- ----- --> :p0 Input String 9 --> :p1 Input String EY10-119 --> :cur1 Output Object
--> Time: 58 ms --> Result: Oracle.DataAccess.Client.OracleDataReader
SELECT COUNT(*) FROM PROCESS.OCALA_STRUCTURE_LOOKUP WHERE
(OCALA_STRUCTURE_LOOKUP.WORK_LOCATION_NUMBER = '10' AND OCALA_STRUCTURE_LOOKUP.WORK_REQUEST_NAME = 'EY10-119')
--> Parameter Direction DbType Value
--> --------- --------- ---------- -----
--> :p0 Input String 10
--> :p1 Input String EY10-119
--> Time: 59 ms
--> Result: 1
BEGIN
OPEN :cur1 FOR
SELECT
OCALA_STRUCTURE_LOOKUP.POLE_NUMBER AS "pole_num_0"
FROM
PROCESS.OCALA_STRUCTURE_LOOKUP
WHERE
(OCALA_STRUCTURE_LOOKUP.WORK_LOCATION_NUMBER = '10' AND OCALA_STRUCTURE_LOOKUP.WORK_REQUEST_NAME = 'EY10-119');
END;
--> Parameter Direction DbType Value
--> --------- --------- ---------- -----
--> :p0 Input String 10
--> :p1 Input String EY10-119
--> :cur1 Output Object
--> Time: 0 ms
|
|
|
I have tried this in a variety of different configurations and am unable to reproduce the "error when string length is greater than 1" issue. Could there be some bad PoleNumber data associated with WorkLocationNumber 10? The only other thing I can think of is that Oracle sometimes messes up char/byte values, which is consistent with the 'length greater than 1' issue but I can't see why it would be thinking something is a char/byte instead of a varchar here. If you are not on a recent nightly build, it is probably worth upgrading to see if the problem still occurs (and so that you and I are working off the same codebase!). If it does still occur, is it possible for you to provide a stripped down repro in the form of: * A buildable project containing the failing code in the form of a NUnit test or console application * A SQL script to build the required table and populate it with data that demonstrates the problem This does not have to be real data or even your real table -- simpler is good! -- just something that reproduces the error. Thanks! |
|