TypeConverter

Posts   
 
    
Skeeterbug
User
Posts: 165
Joined: 21-May-2004
# Posted on: 16-Jan-2007 20:05:54   

I have a problem where the TypeConverter is trying to convert from DBNull to boolean (I am not using nullable types). Here is the query that is being ran:

SELECT DISTINCT "FC"."LeafContainerDetail"."LeafContainerDetailId", "FC"."LeafContainerDetail"."Number", "FC"."LeafContainerDetail"."Title", "FC"."LeafContainerDetail"."FolderElment" AS "FolderElement", "FC"."LeafContainerDetail"."FileName", "FC"."LeafContainerDetail"."DirectoryName", "FC"."LeafContainerDetail"."ParentId", "FC"."LeafContainerDetail"."IsFormule", "FC"."TypeAttributeLeafContainerDet"."IsSpecific", "FC"."TypeAttributeLeafContainerDet"."HasXml", "FC"."TypeAttributeLeafContainerDet"."HasLanguage", "FC"."TypeAttributeLeafContainerDet"."HasProducAtt" AS "HasProductAtt", "FC"."TypeAttributeLeafContainerDet"."HasOnlyPath" FROM ( "FC"."LeafContainerDetail"  LEFT JOIN "FC"."TypeAttributeLeafContainerDet"  ON  "FC"."LeafContainerDetail"."LeafContainerDetailId"="FC"."TypeAttributeLeafContainerDet"."LeafContainerDetailId") WHERE ( ( "FC"."LeafContainerDetail"."RegionId" = :RegionId1 OR "FC"."LeafContainerDetail"."RegionId" IS NULL))

IsSpecific, HasXml, and others are coming back null in the result set in certain rows. Is there something going wrong here?

                    IRelationPredicateBucket lrpbBucket = new RelationPredicateBucket();

                    //Select
                    ResultsetFields lrsFields = new ResultsetFields(12);

                    lrsFields.DefineField(LeafContainerDetailFieldIndex.LeafContainerDetailId, 0, "LeafContainerDetailId");
                    lrsFields.DefineField(LeafContainerDetailFieldIndex.Number, 1, "Number");
                    lrsFields.DefineField(LeafContainerDetailFieldIndex.Title, 2, "Title");
                    lrsFields.DefineField(LeafContainerDetailFieldIndex.FolderElment, 3, "FolderElement");
                    lrsFields.DefineField(LeafContainerDetailFieldIndex.FileName, 4, "FileName");
                    lrsFields.DefineField(LeafContainerDetailFieldIndex.DirectoryName, 5, "DirectoryName");
                    lrsFields.DefineField(LeafContainerDetailFieldIndex.ParentId, 6, "ParentId");
                    lrsFields.DefineField(LeafContainerDetailFieldIndex.IsFormule, 7, "IsFormule");
                    lrsFields.DefineField(TypeAttributeLeafContainerDetailFieldIndex.IsSpecific, 8, "IsSpecific");
                    lrsFields.DefineField(TypeAttributeLeafContainerDetailFieldIndex.HasXml, 9, "HasXml");
                    lrsFields.DefineField(TypeAttributeLeafContainerDetailFieldIndex.HasLanguage, 10, "HasLanguage");
                    lrsFields.DefineField(TypeAttributeLeafContainerDetailFieldIndex.HasProductAtt, 11, "HasProductAtt");

                    //Inner join
                    lrpbBucket.Relations.Add(LeafContainerDetailEntity.Relations.TypeAttributeLeafContainerDetailEntityUsingLeafContainerDetailId, JoinHint.Left);

                    //Where
                    IPredicateExpression lpe = new PredicateExpression();
                    lpe.Add(PredicateFactory.Like(LeafContainerDetailFieldIndex.FileName, "m1%"));
                    lpe.AddWithOr(PredicateFactory.Like(LeafContainerDetailFieldIndex.DirectoryName, "m1%"));

                    lrpbBucket.PredicateExpression.Add(PredicateFactory.CompareValue(LeafContainerDetailFieldIndex.RegionId, ComparisonOperator.Equal, regionId));
                    lrpbBucket.PredicateExpression.Add(lpe);
                    lrpbBucket.PredicateExpression.AddWithOr(PredicateFactory.CompareNull(LeafContainerDetailFieldIndex.RegionId, false));

                    //Fill
                    DataTable ldt = new DataTable();

                    ldaaAdapter.FetchTypedList(lrsFields, ldt, lrpbBucket);

This was working in SQL Server, as it doesn't use the TypeConverters. Any suggestions?

Skeeterbug
User
Posts: 165
Joined: 21-May-2004
# Posted on: 17-Jan-2007 01:02:13   

I added TypeConverters source to my project, and in the ConvertFrom method, I changed it to this:


case "System.DBNull":
toReturn = false;
break;

Not sure if that is right, but it got the job done simple_smile