Online Documentation Does not match actual call(s)

Posts   
 
    
normanlc
User
Posts: 62
Joined: 10-Jan-2007
# Posted on: 30-Dec-2008 03:07:58   

         VwDataEntityTypeTypedView _g_tables = new VwDataEntityTypeTypedView();
         ISortExpression sort = new SortExpression(DataEntityTypeFields.DisplayName |
              SortOperator.Ascending);
         DataAccessAdapter adapter = new DataAccessAdapter(_g_connection_string);
         adapter.FetchTypedView(_g_tables.GetFieldsInfo(), _g_tables, null, 0, sort, true);

         ceTable.DataSource = _g_tables;
         ceTable.DisplayMember = "DisplayName";

         if (ceTable.Items.Count > 0) { ceTable.SelectedIndex = 0; }
         else { ceTable.SelectedIndex = (-1); }

Code similar was found in:

Generated code - Using the typed view classes, Adapter

of the online documentation under Using generated code->Adapter->Using TypedViews, TypedList and Dynamic Lists section

I of course receive an error - Stack Trace

" at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery.Execute(CommandBehavior behavior)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.ExecuteMultiRowDataTableRetrievalQuery(IRetrievalQuery queryToExecute, DbDataAdapter dataAdapterToUse, DataTable tableToFill, IFieldPersistenceInfo[] fieldsPersistenceInfo)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedView(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)\r\n at SD.LLBLGen.Pro.ORMSupportClasses.DataAccessAdapterBase.FetchTypedView(IEntityFields2 fieldCollectionToFetch, DataTable dataTableToFill, IRelationPredicateBucket filterBucket, Int32 maxNumberOfItemsToReturn, ISortExpression sortClauses, Boolean allowDuplicates)\r\n at SPCalls.Form1.Form1_Load(Object sender, EventArgs e) in E:\doubleM Software\dMProbate\VS 2008\dMProbateV2.5b\Test Beds\SPCalls\Form1.cs:line 40\r\n at System.Windows.Forms.Form.OnLoad(EventArgs e)\r\n at System.Windows.Forms.Form.OnCreateControl()\r\n at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)\r\n at System.Windows.Forms.Control.CreateControl()\r\n at System.Windows.Forms.Control.WmShowWindow(Message& m)\r\n at System.Windows.Forms.Control.WndProc(Message& m)\r\n at System.Windows.Forms.ScrollableControl.WndProc(Message& m)\r\n at System.Windows.Forms.ContainerControl.WndProc(Message& m)\r\n at System.Windows.Forms.Form.WmShowWindow(Message& m)\r\n at System.Windows.Forms.Form.WndProc(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)\r\n at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)\r\n at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)\r\n at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)\r\n at System.Windows.Forms.Control.SetVisibleCore(Boolean value)\r\n at System.Windows.Forms.Form.SetVisibleCore(Boolean value)\r\n at System.Windows.Forms.Control.set_Visible(Boolean value)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)\r\n at System.Windows.Forms.Application.Run(Form mainForm)\r\n at SPCalls.Program.Main() in E:\doubleM Software\dMProbate\VS 2008\dMProbateV2.5b\Test Beds\SPCalls\Program.cs:line 18\r\n at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)\r\n at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)\r\n at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()\r\n at System.Threading.ThreadHelper.ThreadStart_Context(Object state)\r\n at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)\r\n at System.Threading.ThreadHelper.ThreadStart()"

Apparently you can't use a DataEntityTypeFields.DisplayName with the sort operation when using a view... however, there is no IEntityField2 interface that I can find for a param to a constructor of either a SortClause or a SortExpression

I've read many times how great the documentation is for this product, but I MUST be dumb as a rock because it's not that easy to find stuff at all! The examples are one out of 10 constructors possible etc.

Any clues...

I'm just trying to use a TypedView, which is support to be most efficient to populate a dropdown list control according to documentation rather than calling a EntityCollection... The sort seems to be the issue.

Thanks in advance.

Norman

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39859
Joined: 17-Aug-2003
# Posted on: 30-Dec-2008 09:40:46   

1) what is the exact error? You post the stacktrace but not the error message 2) what's the runtime lib buildnr? (see guidelines thread in this forum)

Frans Bouma | Lead developer LLBLGen Pro
normanlc
User
Posts: 62
Joined: 10-Jan-2007
# Posted on: 01-Jan-2009 04:57:47   

Otis:

Error Message: "An exception was caught during the execution of a retrieval query: The multi-part identifier "dMProbate.dbo.DataEntityType.DisplayName" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception."

Exception Details: SD.LLBLGen.Pro.ORMSupportClasses.ORMQueryExecutionException was unhandled Message="An exception was caught during the execution of a retrieval query: The multi-part identifier \"dMProbate.dbo.DataEntityType.DisplayName\" could not be bound.. Check InnerException, QueryExecuted and Parameters of this exception to examine the cause of this exception." Source="SD.LLBLGen.Pro.ORMSupportClasses.NET20" RuntimeBuild="06192008" RuntimeVersion="2.6.0.0" QueryExecuted="\r\n\tQuery: SELECT [dMProbate].[dbo].[vw_DataEntityType].[EnumValue], [dMProbate].[dbo].[vw_DataEntityType].[EnumName], [dMProbate].[dbo].[vw_DataEntityType].[DisplayName], [dMProbate].[dbo].[vw_DataEntityType].[DisplayTemplateName], [dMProbate].[dbo].[vw_DataEntityType].[DisplayPosition], [dMProbate].[dbo].[vw_DataEntityType].[RowVersion] FROM [dMProbate].[dbo].[vw_DataEntityType] ORDER BY [dMProbate].[dbo].[DataEntityType].[DisplayName] ASC\r\n"

[Snip] [Snip] <Stack Trace already provided in previous post> [Snip][Snip]

In the help about it states: 2.6 Final Released on June 6th

The information above states the RuntimeBuild is: 06/19/2008

In the Add Reference Portion of MSVS Add Reference for .NET it states: Version: 2.6.0.0 Runtime v2.0.50727

Hope this helps.

Norman

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Jan-2009 08:55:19   

That's because you are using the wrong fields enum in the sortExpression. You should use that of the TypedView.

ISortExpression sort = new SortExpression(DataEntityTypeFields.DisplayName | SortOperator.Ascending);

Should be changed to:

ISortExpression sort = new SortExpression(VwDataEntityTypeFields.DisplayName |
             SortOperator.Ascending);

The documentation didn't have the same mistake.

As a side note, I recommend you upgrade to the latest version of the runtime library, as you are using an old one.

normanlc
User
Posts: 62
Joined: 10-Jan-2007
# Posted on: 01-Jan-2009 09:38:16   

Walaa:

Thanks for you response, but I do not agree with your assessment of the documentation:

// C#
InvoicesTypedView invoices = new InvoicesTypedView();
// simply fetch the 2nd page of 25 rows. We specify no filter, 
// no group by collection and we specify 0 for the max number of elements to return which means
// all of them. We also specify that we don't care about duplicate rows. 
// We do specify a sort expression, as paging without a sorter isn't really reliable. 
SortExpression sorter = new SortExpression();
sorter.Add(InvoicesFields.OrderId | SortOperator.Ascending);
using(DataAccessAdapter adapter = new DataAccessAdapter())
{
    adapter.FetchTypedView(invoices.GetFieldsInfo(), invoices, null, 0, sorter, true, null, 2, 25);
}

// Now that invoices is filled with data, we'll show it in the viewer.
Viewer v = new Viewer();
v.BindDataTable(invoices);
v.ShowDialog();
'

Above where is states "sorter.Add(InvoicesFields.OrderId | SortOperator.Ascending);" appears to me to be what I've followed and I see it as entity fields rather than the view fields??? If it were, wouldn't it be InvoicesTypedViewFields??? That is if I follow the logic you've expressed as it relates to my code.

If I'm incorrect then I'm correct in "I'm dumb as a rock" because it sure appears as I've mentioned. Either way, documentation is not clear to me. Sorry I don't know this product as well as you. It's not worth arguing over.

You were correct as it relates to my code, and I thank you once again.

Norman

Walaa avatar
Walaa
Support Team
Posts: 14993
Joined: 21-Aug-2005
# Posted on: 01-Jan-2009 09:50:30   

Above where is states "sorter.Add(InvoicesFields.OrderId | SortOperator.Ascending);" appears to me to be what I've followed and I see it as entity fields rather than the view fields??? If it were, wouldn't it be InvoicesTypedViewFields??? That is if I follow the logic you've expressed as it relates to my code

I'm afraid you are mistaken here too simple_smile If you check my posted code, you'd find that I had stripped the TypedView out of the name of the enum to be: VwDataEntityTypeFields.

See the docs examples are based on Northwind, there exists a TypedView called InvoicesTypedView, and there is no Entity called InvoiceEntity.

The general rule is that fields enums are named after their TypedViews or Entities names after stripping the last part. (TypedView or Entity).

So for a CustomerEntity, the fields enum would be CustomerFields. And for an InvoiceTypedView the enum would be InvoiceFields.

And there is no way you are going to have an InvoiceEntity and an InvoiceTypedView in the same project, coz you can't have a table and a view in the database with the same name "Invoice".

(EDIT) Anyway you may have a point about the docs, it's huge (600+) and we are always modifying it to make it simpler for users, and your point is well taken. We are always available on the forums to clear any misunderstanding and to receive users requests too.