1. Thomas Rolseth
  2. SnapDevelop
  3. Monday, 4 May 2020 15:51 PM UTC

The SelectToStore<> method has been deprecated in SnapDevelop 2.0.  We used this extensively in v1.0.  What is the replacement for this this?  How should our code be modified?

We used this to get values from SELECT statements like so:

var result = _dataContext.SqlExecutor.SelectToStore<DynamicModel>(sql, as_param1);

Thanks, Tom

Accepted Answer
Logan Liu @Appeon Accepted Answer Pending Moderation
  1. Tuesday, 5 May 2020 05:25 AM UTC
  2. SnapDevelop
  3. # Permalink

Hi Tom,

Yes. You can replace SqlExecutor.SelectToStore<DynamicModel> with SqlExecutor.Select<DynamicModel> method.

BTW: The SelectToStore method was extended for ModelStore<TModel> in the last version, but ModelStore<TModel> has been deprecated in DWNet.Data 2.0.0. We already support DataStore<T>, which can be used to replace ModelStore <TModel> in most cases.

Regards,

Logan

 

 

Comment
  1. Thomas Rolseth
  2. Tuesday, 5 May 2020 13:43 PM UTC
Thanks. To my other related question, switching to SqlExecutor.Select<DynamicModel> method means we can no longer use:



as_type = result.GetValue<string>(0, "srv_type");



It doesn't like the row index indicator anymore. Is it no longer possible to do this with GetValue?
  1. Helpful
  1. Logan Liu @Appeon
  2. Tuesday, 5 May 2020 14:16 PM UTC
Yes. It returns an IList<TModel> object. You need to use a different way to get the value.

E.g.:

var result = _dataContext.SqlExecutor.SelectToStore<DynamicModel>(sql, as_param1);

as_type = result[0].GetValue<string>( "srv_type");

  1. Helpful
There are no comments made yet.
Thomas Rolseth Accepted Answer Pending Moderation
  1. Monday, 4 May 2020 15:59 PM UTC
  2. SnapDevelop
  3. # 1

Would we just replace 'SelectToStore' with 'Select' like so?

var result = _dataContext.SqlExecutor.Select<DynamicModel>(sql, as_param1);

Comment
  1. Thomas Rolseth
  2. Monday, 4 May 2020 21:53 PM UTC
I also noticed that if we did switch to Select<DynamicModel> we can't use GetValue in the same manner. Currently we use it as follows with an index representing the row number:



as_type = result.GetValue<string>(0, "srv_type");



Has that been deprecated as well? If so, is there a workaround?
  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.