Problem With CreateSelectDQ (Obsolete override)

Posts   
 
    
RolandE
User
Posts: 7
Joined: 06-Nov-2007
# Posted on: 07-Nov-2007 14:42:23   

I am currently using the following code:


                IPredicateExpression Pred;
                ISortExpression Sort;
                IRetrievalQuery selectQuery;
                IEntityFields fieldsInResultset;
                TypedViewType ViewType;
                EntityType EntType;
                string sSQL;

                // get resulting field list from view/table 
                if (UseView)
                {
                    ViewType = (TypedViewType)Enum.Parse(typeof(TypedViewType), ViewName + "TypedView");
                    fieldsInResultset = EntityFieldsFactory.CreateTypedViewEntityFieldsObject(ViewType);
                }
                else
                {
                    EntType = (EntityType)Enum.Parse(typeof(EntityType), TableName + "Entity");
                    fieldsInResultset = EntityFieldsFactory.CreateEntityFieldsObject(EntType);
                }

                // create sql statement with filter and sort 
                DynamicQueryEngine DQE = new DynamicQueryEngine();

                Pred = BuildGenericFilterExpression(Filter, null, ShowDeleted, ShowInvalid);
                Sort = BuildGenericSortExpression(SortKeys);
                selectQuery =
                    DQE.CreateSelectDQ(fieldsInResultset,
                                       DbUtils.DetermineConnectionToUse(null),
                                       Pred, ConfigurationManager.MaxRows, Sort,
                                       null);

But VS tells me that this Override (IEntityFields) is obsolete.

VS announces this as an Error (not as a Warning) and now the whole project cannot be built.

Is there a function that converts IEntityFields to IEntityFieldCore[]?

many thanks in advance.

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Nov-2007 15:14:12   

Are you using SelfServicing or Adapter?

RolandE
User
Posts: 7
Joined: 06-Nov-2007
# Posted on: 07-Nov-2007 15:18:20   

Sorry! I forgot this: I use SelfServicing

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Nov-2007 15:57:38   

Is this the line causing tyhe compilation error?

selectQuery = DQE.CreateSelectDQ(fieldsInResultset, DbUtils.DetermineConnectionToUse(null), Pred, ConfigurationManager.MaxRows, Sort, null);

Going back to v.2.5 reference manul, it tells that this is indeed an obsolete overload:

This method is now obsolete and shouldn't be used in your code. Instead, use the overload which accepts an IEntityFieldCore[] object and an IFieldPersistenceInfo[] object.

Just for the sake of trial, will the following compile:

selectQuery =
                    DQE.CreateSelectDQ(fieldsInResultset, null
                                     DbUtils.DetermineConnectionToUse(null),
                                     Pred, ConfigurationManager.MaxRows, Sort,
                                     null);
RolandE
User
Posts: 7
Joined: 06-Nov-2007
# Posted on: 07-Nov-2007 16:02:33   

No it doesn't because there is no such overload!

I tried


selectQuery =
                    DQE.CreateSelectDQ(fieldsInResultset, null
                                     DbUtils.DetermineConnectionToUse(null),
                                     Pred, ConfigurationManager.MaxRows, Sort,
                                     null);

and


selectQuery =
                    DQE.CreateSelectDQ(null
                                     DbUtils.DetermineConnectionToUse(null),
                                     Pred, ConfigurationManager.MaxRows, Sort,
                                     null);

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 07-Nov-2007 16:46:04   

fieldsForQuery.GetAsEntityFieldCoreArray()

Found it:

myEntityFields.GetAsEntityFieldCoreArray();

(EDIT) Also use the following to get the fieldsPersistenceInfo[]

myEntityFields.GetAsPersistenceInfoArray();