I’m a new user and the docs on this feature are crystal clear, however what the docs say and how my code behaves seems to be exactly opposite, so I must be doing something stupid.
If I want to exclude fields I should set ExcludeContainedFields = false, however the resulting query includes everything except the field I want. Setting it to true does the exact opposite.
There is nothing special about the single field I want to fetch (not PK or FK).
The docs clearly say, “When ExcludeContainedFields is set to false, the fields added to the instance of should be seen as the fields to fetch.”
// only include MostRecentTitleReportHistoryId field
ExcludeIncludeFieldsList excludedFields = new ExcludeIncludeFieldsList();
excludedFields.ExcludeContainedFields = false;
excludedFields.Add(AfwOrderFields.MostRecentTitleReportHistoryId);
AfwOrderEntity afwOrderEntity = new AfwOrderEntity(afwOrderId);
adapter.FetchExcludedFields(afwOrderEntity, excludedFields);
Generated Sql query:
Query: SELECT TOP(@p2) [AfwOrder].[AfwOrderId], [AfwOrder].[FileStorCustomerOrderCounter], [AfwOrder].[FileStorInvoiceCounter], [AfwOrder].[FileStorOrderSheetCounter], [AfwOrder].[FileStorTitleReportCounter], [AfwOrder].[InsertedDate], [AfwOrder].[InsertedUser], [AfwOrder].[IsInstantInvoice], [AfwOrder].[LastUpdatedDate], [AfwOrder].[LastUpdatedUser], [AfwOrder].[OrderKey] FROM [AfwOrder] WHERE ( ( ( [AfwOrder].[AfwOrderId] IN (@p3))))
Parameter: @p2 : Int64. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 250.
Parameter: @p3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.
// only include MostRecentTitleReportHistoryId field
ExcludeIncludeFieldsList excludedFields = new ExcludeIncludeFieldsList();
excludedFields.ExcludeContainedFields = true;
excludedFields.Add(AfwOrderFields.MostRecentTitleReportHistoryId);
AfwOrderEntity afwOrderEntity = new AfwOrderEntity(afwOrderId);
adapter.FetchExcludedFields(afwOrderEntity, excludedFields);
Generated Sql query:
Query: SELECT TOP(@p2) [AfwOrder].[AfwOrderId], [AfwOrder].[MostRecentTitleReportHistoryId] FROM [AfwOrder] WHERE ( ( ( [AfwOrder].[AfwOrderId] IN (@p3))))
Parameter: @p2 : Int64. Length: 0. Precision: 0. Scale: 0. Direction: Input. Value: 250.
Parameter: @p3 : Int32. Length: 0. Precision: 10. Scale: 0. Direction: Input. Value: 2.