Developer forum

Forum » Development » RE: Dynamicweb.eCommerce.Products.GroupCollection.Load(string)' is obsolete

RE: Dynamicweb.eCommerce.Products.GroupCollection.Load(string)' is obsolete

Stefan Thordarson
Reply

DW Support suggested to use this forum, hopefully someone can suggest an alternative  to GroupCollection.Load(string sql).

 

DESCRIPTION: 
We use GroupCollection to load data from the datebase. This code generates a deprecation Warning.

GroupCollection g = new GroupCollection();
g.Load("select * from sometable");
Then foreach item in collection we want to read or delete data.

 

Please adwise an alternative solution, to avoid using the Load function. If You have no adwise, then the Load function must no longer be obsolete, since our customers production environment is relying on this function.

http://developer.dynamicweb-cms.com/api/ecommerce/Dynamicweb~Dynamicweb.eCommerce.Products.GroupCollection~Load(String).html

STEPS TO REPRODUCE:
Compiler generated warning.

BUSINESS IMPACT:
We do not want to risc deprecationproblems in future release update of DW. Therefore an alternative solution must be implemented, as long as DW really is planning to deprecate the Load function ? 

We might be stuck with current DW version, which might end up being crucical, since most DW-problems must be solved by updating to newer release.


Replies

 
Nicolai Høeg Pedersen
Reply
This post has been marked as an answer

Hi Stefan

You can use the Group.GetGroupsBy* methods to get groups from the system: http://developer.dynamicweb-cms.com/api8/#Dynamicweb~Dynamicweb.eCommerce.Products.Group.html. Make sure you use the Dynamicweb 8 API reference and not the Dynamicweb 7.

The load method is deprecated since it loads from the database and not the memory cache. You can also use Group.GetAllGroups() and apply a LINQ statement. The all groups runs on the cache as well.

If a SQL is required you can do like this:

Dim myProductCollection As New GroupCollection()

Using reader As IDataReader = Database.CreateDataReader(String.Format("SELECT * FROM [EcomGroups] WHERE [GroupID] IN ({0})",

String.Join(",", Array.ConvertAll(notFoundGroupIDs.ToArray(), Function(item As String) String.Format("'{0}'", item)))), "Ecom.mdb")

While reader.Read()

group = New Group(reader)

myProductCollection.Add(group)

End While

End Using

Votes for this answer: 1
 
Stefan Thordarson
Reply

Thanks for good answer and the code-example. Works perfectly yes

 

You must be logged in to post in the forum