LLBLGen with XtraGrid in sever mode?

Posts   
 
    
pat
User
Posts: 215
Joined: 02-Mar-2006
# Posted on: 07-Feb-2009 02:31:16   

Hi,

I was wondering if anybody is successfully using LINQ to LLBLGen with the DevExpress XtraGrid in server mode?

I did some test for a few minutes but as soon as I used filtering, or an entity in a hierarchy it wouldn't work anymore.

Thanks for any help, Patrick

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 07-Feb-2009 03:01:35   

I used ServerMode with a LookupEdit successfully. I thought all controls worked off the same API. It should work for you as well. One thing that you might have done is dispose the adapter that the queryable is using. This would for sure make it choke.

pat
User
Posts: 215
Joined: 02-Mar-2006
# Posted on: 07-Feb-2009 14:03:29   

Here is the code I use (it's from other threads in the forum): Otherwise there is no code on the form.

protected override void OnLoad(EventArgs e)
{
    base.OnLoad(e);

    if (this.DesignMode) return;

var da = new DataAccessAdapter(true);
//da.StartTransaction(System.Data.IsolationLevel.ReadUncommitted, "CreateNoLockAdapter");
var metaData = new LinqMetaData(da);

linqServerModeSource1.ElementType = typeof(DAL.EntityClasses.MyItemVersionBaseEntity);
linqServerModeSource1.KeyExpression = "ItemVersionId";
var q = (from c in metaData.ItemVersionBase
 select c);

linqServerModeSource1.QueryableSource = q;

gridControl1.DataSource = linqServerModeSource1;
gridControl1.ServerMode = true;
}

As soon as I use an auto filter it says object not set to an instance and mentions "ItemVersionId" even though it does exist and worked in the first place to fill the grid.

Thanks, Patrick

Seth avatar
Seth
User
Posts: 204
Joined: 25-Mar-2006
# Posted on: 08-Feb-2009 00:06:31   

I think I have the queryable object as a member of the class and not a member of the function itself. Although theoretically the reference should be maintained by the garbage collector. Try that and see what happens.

pat
User
Posts: 215
Joined: 02-Mar-2006
# Posted on: 08-Feb-2009 04:50:51   

Seth wrote:

I think I have the queryable object as a member of the class and not a member of the function itself.

Thank you it didn't make a difference...

Here is what happens:

SELECT LPA_L1.SubTypeID
FROM  (SELECT F11_2
               FROM   (SELECT LPA_L4.ItemVersionId AS F11_0, LPA_L4.ItemId AS F11_1, LPA_L4.SubClassTypeID AS F11_2
                               FROM   ItemVersion AS LPA_L4 LEFT OUTER JOIN
                                              ItemVersionData AS LPA_L5 ON LPA_L4.ItemVersionId = LPA_L5.ItemVersionId LEFT OUTER JOIN
                                              ItemVersionTake AS LPA_L6 ON LPA_L4.ItemVersionId = LPA_L6.ItemVersionId) AS LPA_L3
               GROUP BY F11_2) AS LPA_L1
ORDER BY LPA_L1.SubTypeID

With this error message: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException occurred Message="An exception was caught during the execution of a retrieval query: Invalid column name 'SubTypeID'.\r\nInvalid column name 'SubTypeID'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception." Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20" RuntimeBuild="01162009" RuntimeVersion="2.6.0.0"

As you see something went wrong with the aliases. I removed some fields from the select to make it shorter by the way.

Thanks, Patrick

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 09-Feb-2009 09:30:36   

SELECT LPA_L1.SubTypeID FROM (SELECT F11_2 FROM (SELECT LPA_L4.ItemVersionId AS F11_0, LPA_L4.ItemId AS F11_1, LPA_L4.SubClassTypeID AS F11_2 FROM ItemVersion AS LPA_L4 LEFT OUTER JOIN ItemVersionData AS LPA_L5 ON LPA_L4.ItemVersionId = LPA_L5.ItemVersionId LEFT OUTER JOIN ItemVersionTake AS LPA_L6 ON LPA_L4.ItemVersionId = LPA_L6.ItemVersionId) AS LPA_L3 GROUP BY F11_2) AS LPA_L1 ORDER BY LPA_L1.SubTypeID

Nothing wrong with the aliases, the thing is there is no SubTypeID field to select in the outer most query.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 09-Feb-2009 16:59:04   

Looks like an inheritance related problem, however these should work OK as well.

Could you post more relevant info? I.e. switch on tracing on level 3 for the Linq provider in the config file of your application, so you'll see the expression tree in text. Then describe the inheritance hierarchy of the entities involved and their tables.

Frans Bouma | Lead developer LLBLGen Pro
pat
User
Posts: 215
Joined: 02-Mar-2006
# Posted on: 13-Feb-2009 04:22:25   

Otis wrote:

Could you post more relevant info?

Tables: ItemVersion > ItemVersionData ItemVersion >ItemVersionTake

Inheritance: MyItemVersionBaseEntity > MyItemVersionDataEntity MyItemVersionBaseEntity >MyItemVersionTakeEntity

Trace:

: Initial expression to process:
value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[CFX.Amanda.DAL.EntityClasses.MyItemVersionBaseEntity]).Select(c => c).GroupBy( => .SubTypeID).OrderBy( => .Key).Select( => .Key)
Method Enter: CreatePagingSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSubQuery
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Method Enter: CreateSubQuery
Method Enter: CreateSelectDQ
Method Enter: CreateSelectDQ
Generated Sql query: 
    Query: SELECT [LPA_L4].[ItemVersionId] AS [F11_0], [LPA_L4].[ItemId] AS [F11_1], [LPA_L4].[SubClassTypeID] AS [F11_2], [LPA_L4].[VersionNumber] AS [F11_3] FROM (( [dbo].[ItemVersion] [LPA_L4]  LEFT JOIN [dbo].[ItemVersionData] [LPA_L5]  ON  [LPA_L4].[ItemVersionId]=[LPA_L5].[ItemVersionId]) LEFT JOIN [dbo].[ItemVersionTake] [LPA_L6]  ON  [LPA_L4].[ItemVersionId]=[LPA_L6].[ItemVersionId])

Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query: 
    Query: SELECT [LPA_L3].[F11_2] FROM (SELECT [LPA_L4].[ItemVersionId] AS [F11_0], [LPA_L4].[ItemId] AS [F11_1], [LPA_L4].[SubClassTypeID] AS [F11_2], [LPA_L4].[VersionNumber] AS [F11_3] FROM (( [dbo].[ItemVersion] [LPA_L4]  LEFT JOIN [dbo].[ItemVersionData] [LPA_L5]  ON  [LPA_L4].[ItemVersionId]=[LPA_L5].[ItemVersionId]) LEFT JOIN [dbo].[ItemVersionTake] [LPA_L6]  ON  [LPA_L4].[ItemVersionId]=[LPA_L6].[ItemVersionId])) [LPA_L3] GROUP BY [LPA_L3].[F11_2]

Method Exit: CreateSelectDQ
Method Exit: CreateSubQuery
Generated Sql query: 
    Query: SELECT [LPA_L1].[SubTypeID] FROM (SELECT [LPA_L3].[F11_2] FROM (SELECT [LPA_L4].[ItemVersionId] AS [F11_0], [LPA_L4].[ItemId] AS [F11_1], [LPA_L4].[SubClassTypeID] AS [F11_2], [LPA_L4].[VersionNumber] AS [F11_3] FROM (( [dbo].[ItemVersion] [LPA_L4]  LEFT JOIN [dbo].[ItemVersionData] [LPA_L5]  ON  [LPA_L4].[ItemVersionId]=[LPA_L5].[ItemVersionId]) LEFT JOIN [dbo].[ItemVersionTake] [LPA_L6]  ON  [LPA_L4].[ItemVersionId]=[LPA_L6].[ItemVersionId])) [LPA_L3] GROUP BY [LPA_L3].[F11_2]) [LPA_L1] ORDER BY [LPA_L1].[SubTypeID] ASC

Method Exit: CreateSelectDQ
Method Exit: CreatePagingSelectDQ: no paging.

Error:

SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException occurred
  Message="An exception was caught during the execution of a retrieval query: Invalid column name 'SubTypeID'.\r\nInvalid column name 'SubTypeID'.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."
  Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20"
  RuntimeBuild="01162009"
  RuntimeVersion="2.6.0.0"
  QueryExecuted="\r\n\tQuery: SELECT [LPA_L1].[SubTypeID] FROM (SELECT [LPA_L3].[F11_2] FROM (SELECT [LPA_L4].[ItemVersionId] AS [F11_0], [LPA_L4].[ItemId] AS [F11_1], [LPA_L4].[SubClassTypeID] AS [F11_2], [LPA_L4].[VersionNumber] AS [F11_3] FROM (( [dbo].[ItemVersion] [LPA_L4]  LEFT JOIN [dbo].[ItemVersionData] [LPA_L5]  ON  [LPA_L4].[ItemVersionId]=[LPA_L5].[ItemVersionId]) LEFT JOIN [dbo].[ItemVersionTake] [LPA_L6]  ON  [LPA_L4].[ItemVersionId]=[LPA_L6].[ItemVersionId])) [LPA_L3] GROUP BY [LPA_L3].[F11_2]) [LPA_L1] ORDER BY [LPA_L1].[SubTypeID] ASC\r\n"
  StackTrace:
       at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
       at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchDataReader(IRetrievalQuery queryToExecute, CommandBehavior readerBehavior)
       at CFX.Amanda.DAL.DatabaseSpecific.DataAccessAdapter.FetchDataReader(IRetrievalQuery queryToExecute, CommandBehavior readerBehavior) in D:\Dev\VS\CFX.Amanda\Trunk\src\CFX.Amanda.DAL\DatabaseSpecific\DataAccessAdapter.cs:line 292
  InnerException: System.Data.SqlClient.SqlException
       Message="Invalid column name 'SubTypeID'.\r\nInvalid column name 'SubTypeID'."
       Source=".Net SqlClient Data Provider"
       ErrorCode=-2146232060
       Class=16
       LineNumber=1
       Number=207
       Procedure=""
       Server="FA-SQL-001"
       State=1
       StackTrace:
            at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
            at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
            at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
            at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
            at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
            at System.Data.SqlClient.SqlDataReader.get_MetaData()
            at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
            at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
            at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
            at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
            at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
            at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
            at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
            at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)
       InnerException: 

Thanks, Patrick

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 13-Feb-2009 09:04:28   

pat wrote:

Otis wrote:

Could you post more relevant info?

Tables: ItemVersion > ItemVersionData ItemVersion >ItemVersionTake

Inheritance: MyItemVersionBaseEntity > MyItemVersionDataEntity MyItemVersionBaseEntity >MyItemVersionTakeEntity

Trace: [code]: Initial expression to process: value(SD.LLBLGen.Pro.LinqSupportClasses.DataSource2`1[CFX.Amanda.DAL.EntityClasses.MyItemVersionBaseEntity]).Select(c => c).GroupBy( => .SubTypeID).OrderBy( => .Key).Select( => .Key)

When I ask for more info, please provide ALL info you can provide. The query targets 1 entity only. The 'My' prefixes, is that due to adapter two-class scenario? What's the tables look like? What's the inheritance type? Remember, I don't see your code in front of me, so I need ALL information you can provide me to reproduce it, otherwise we've to give up and ask for a repro case build by you.

Thanks.

Frans Bouma | Lead developer LLBLGen Pro