nopCommerce 4.40 - Bug fixes and improvements

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
3 年 前
Nop-Templates.com wrote:
I've also noticed that the ShoppingCartModelFactory.PrepareCartItemPictureModel method is now protected and is not present in the interface...

Anton, thanks a lot for the suggestion! But we've decided not to mark these methods as public. Otherwise, we'll have to mark all protected methods as public (in the entire solution) just in case of someone could use it. I hope for your understanding
3 年 前
foxnetsoft wrote:
1. Please upgrade the library Microsoft.Bcl.AsyncInterfaces


What do you mean by "upgrade"? We don't have such a library among included through NuGet in the project.

foxnetsoft wrote:
2. Add the new parameter in the model EstimateShippingModel
        public string City{ get; set; }
DHL and other parcel services doesn't use ZipPostalCode for many countries (only City)
and It's better to add parameters "Hide City", "Hide ZipPostalCode " for EstimateShipping widget


Here is a work item.
3 年 前
>RomanovM
I created the nop 4.40 from the source code and and I saw Microsoft.Bcl.AsyncInterfaces.dll  in the root folder.
Maybe Visual Studio added it.
You are right, I didn't see the direct reference to this library in the csproj files.
I am sorry.
3 年 前
Can you think how to use Async for linq2db queries?
Example

Your code
command.QueryProc<T>()
currentConnection.Query
dataContext.Query<T>
Async code
await command.QueryProcAsync<T>()
await currentConnection.QueryAsync
await dataContext.QueryAsync<T>

Example
        public virtual async Task<IList<T>> QueryProcAsync<T>(string procedureName, params DataParameter[] parameters)
        {
            using var dataContext = await CreateDataConnectionAsync();
            var command = new CommandInfo(dataContext, procedureName, parameters);
            //var rez = command.QueryProc<T>()?.ToList();
            var rez = (await command.QueryProcAsync<T>())?.ToList();
or
            var rez = await (await command.QueryProcAsync<T>())?.ToListAsync();
            UpdateOutputParameters(dataContext, parameters);
            return rez ?? new List<T>();
        }
3 年 前
Pay attention.
I tried to implement  QueryProcMultipleAsync  and I couldn't do it.
and I use in my plugins QueryProcMultiple.
3 年 前
@foxnetsoft
It's not clear to me what you're trying to do.  Note this in the EnityRepository.cs
public virtual async Task<IList<TEntity>> EntityFromSqlAsync(string procedureName, params DataParameter[] parameters)
{
  return await _dataProvider.QueryProcAsync<TEntity>(procedureName, parameters?.ToArray());
}
3 年 前
Open the file BaseDataProvider.cs

        public virtual async Task<IList<T>> QueryAsync<T>(string sql, params DataParameter[] parameters)
        {
            using var dataContext = await CreateDataConnectionAsync();
            return dataContext.Query<T>(sql, parameters)?.ToList() ?? new List<T>();
        }

        public virtual async Task<IList<T>> QueryProcAsync<T>(string procedureName, params DataParameter[] parameters)
        {
            using var dataContext = await CreateDataConnectionAsync();
            var command = new CommandInfo(dataContext, procedureName, parameters);
            var rez = command.QueryProc<T>()?.ToList();
            UpdateOutputParameters(dataContext, parameters);
            return rez ?? new List<T>();
        }
3 年 前
a.m. wrote:

Anton, thanks a lot for the suggestion! But we've decided not to mark these methods as public. Otherwise, we'll have to mark all protected methods as public (in the entire solution) just in case of someone could use it. I hope for your understanding


Hi Andrei,

Please note that we don't ask you to change all protected methods to public in the entire solution.
We only want the ones in the Model factories to be public.
Of course, we understand that since they are not used from outside they should be protected but from an extensibility point of view, we think that it makes sense to make them public.

Since these factories contain common logic that is used in the controllers and components of nopCommerce then it is quite useful for plugin developers to "re-use" this logic.
Otherwise, we will need to "copy" this logic and duplicate that code in our plugins.
Of course, we can easily do that but the problem is that if someone overrides these factories with their own implementation then they will not be able to have their custom logic in our plugins (since we will not use the factories but our own "copy" of the logic).
Basically, we are now going a few years back and be in the situation we were in the previous versions of nopCommerce when the logic was in protected methods in the controllers and we had to inherit from the controllers in order to reuse the logic.  At least then the logic was shared since we inherited the controllers and reused the same protected methods but now we can't reuse it.
Now the logic is properly extracted into model factories but they are not easily accessible.

I hope you will reconsider this and make an exception for the methods in the Model factories.
Even if the nopCommerce team does not use these methods outside of the factories it doesn't mean that we (as plugin developers) won't need to use them in our plugins (actually we use them a lot).

Thanks a lot!
Boyko
3 年 前
foxnetsoft wrote:
Open the file BaseDataProvider.cs
...

OK, so what?  (Are you trying to override the virtual method?)
3 年 前
I want to see this code in the native  nopcommerce

var rez = (await command.QueryProcAsync<T>())?.ToList();
This is the old code
var rez = command.QueryProc<T>()?.ToList();
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.