Generated DynamicQuery for TypedList generates ORA-00936

Posts   
 
    
Posts: 77
Joined: 05-May-2005
# Posted on: 01-Jul-2020 04:51:13   

The TypedList is a very simple one, just one table join 3 columns. If I use the PocoWithLinqQuery, it works fine. But if I use the PocoWithQuerySpecQuery I get the described error. I need to be able to use the QuerySpec option because I need to add a where clause to the query. Any help with this would be greatly appreciated. I have never used these typed lists before, but cannot find another good way to be able to design Crystal Reports. Yes, I know they are horrible to work with, but I can't get away from them. Legacy application.

This is the generated QueryFactory method:

        public DynamicQuery<CTS.Cubic.MoneyRoom.LLBLGenOMNY.TypedListClasses.Col002Row> GetCol002TypedList(
EntityQuery<NfCashboxInventoryEntity> root=null)
        {
            var rootOfQuery = root ?? this.NfCashboxInventory;
            return this.Create()
                        .Select(() => new CTS.Cubic.MoneyRoom.LLBLGenOMNY.TypedListClasses.Col002Row()
                                {
                                    TransportSealId = CashboxInventoryOmnyMrFields.TransportSealId.Source("TransportExt").ToValue<Nullable<System.Int64>>(),
                                    CashboxTypeId = NfCashboxInventoryFields.CashboxTypeId.Source("Transport").ToValue<System.Int32>(),
                                    ReconciliationId = NfCashboxInventoryFields.ReconciliationId.Source("Transport").ToValue<System.String>()
                                })
                        .From(rootOfQuery.As("Transport")
                                .LeftJoin(this.CashboxInventoryOmnyMr.As("TransportExt"))
.On(NfCashboxInventoryFields.CashboxTypeId.Source("Transport").Equal(CashboxInventoryOmnyMrFields.CashboxTypeId.Source("TransportExt"))
.And(NfCashboxInventoryFields.ReconciliationId.Source("Transport").Equal(CashboxInventoryOmnyMrFields.ReconciliationId.Source("TransportExt")))));
        }

This is the TypedRow class:

//////////////////////////////////////////////////////////////
// <auto-generated>This code was generated by LLBLGen Pro v5.5.</auto-generated>
//////////////////////////////////////////////////////////////
// Code is generated on: 
// Code is generated using templates: SD.TemplateBindings.SharedTemplates
// Templates vendor: Solutions Design.
//////////////////////////////////////////////////////////////
using System;

namespace CTS.Cubic.MoneyRoom.LLBLGenOMNY.TypedListClasses
{
    /// <summary>Class which represents a row in the typed list 'MrNyct.Col002'.</summary>
    /// <remarks>This class is a result class for a query, which is produced with the method <see cref="CTS.Cubic.MoneyRoom.LLBLGenOMNY.FactoryClasses.QueryFactory.GetCol002TypedList"/>.
    /// Contains the following entity definition(s):
    /// Entity: MrNyct.NfCashboxInventory.  Aliassed as: Transport <br/>
    /// Entity: MrNyct.CashboxInventoryOmnyMr.  Aliassed as: TransportExt <br/>
    /// </remarks>
    [Serializable]
    public partial class Col002Row 
    {
        partial void OnCreated();
        
        /// <summary>Initializes a new instance of the <see cref="Col002Row"/> class.</summary>
        public Col002Row()
        {
            OnCreated();
        }

        /// <summary>Gets or sets the TransportSealId field. Mapped onto 'TransportExt.TransportSealId'</summary>
        public Nullable<System.Int64> TransportSealId { get; set; }
        /// <summary>Gets or sets the CashboxTypeId field. Mapped onto 'Transport.CashboxTypeId'</summary>
        public System.Int32 CashboxTypeId { get; set; }
        /// <summary>Gets or sets the ReconciliationId field. Mapped onto 'Transport.ReconciliationId'</summary>
        public System.String ReconciliationId { get; set; }
    }
}

And this is how I am executing the query:
        [TestMethod]
        public void QueryFactoryTest002()
        {
            QueryFactory qf = new QueryFactory();
            DynamicQuery<Col002Row> dq = qf.GetCol002TypedList();
            try
            {
                adapter.FetchQuery<Col002Row>(dq.ToString());
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
        }

LLBLGen version: 5.5.7 Build date 25-May-2020 ORMSupportClasses: 5.5.7 Database: Oracle 12g ODP.NET client StackTrace: at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\Query\RetrievalQuery.cs:line 119 at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterCore.FetchDataReader(IRetrievalQuery queryToExecute, CommandBehavior readerBehavior) in C:\Myprojects\VS.NET Projects\LLBLGen Pro v5.5\Frameworks\LLBLGen Pro\RuntimeLibraries\ORMSupportClasses\AdapterSpecific\DataAccessAdapterCore.cs:line 1487 at CTS.Cubic.MoneyRoom.LLBLGenOMNY.Oracle.DataAccessAdapter.FetchDataReader(IRetrievalQuery query, CommandBehavior readerBehavior) in V:\TFS\MoneyRoom\NYCT\src\LLBLGenOMNYOracle\DataAccessAdapter.cs:line 529

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39749
Joined: 17-Aug-2003
# Posted on: 01-Jul-2020 10:13:43   

I see what's wrong, you shouldn't do dq.ToString().

You have to add

using SD.LLBLGen.Pro.QuerySpec.Adapter;

to the top of the file to get access to the extension methods. The 'FetchQuery' method you're calling is the one for plain sql.

After doing the above, you can execute teh query as:

var result = adapter.FetchQuery(dq);

'result' is a List<CTS.Cubic.MoneyRoom.LLBLGenOMNY.TypedListClasses.Col002Row>

Frans Bouma | Lead developer LLBLGen Pro
Posts: 77
Joined: 05-May-2005
# Posted on: 01-Jul-2020 21:09:53   

Sigh. Color me sheepish. I figured it was something I was not doing properly. Works just fine now. Thanks!