neisbut / EntityFramework.MemoryJoin

Extension for EntityFramework for joins to in-memory data
MIT License
56 stars 24 forks source link

Reuse the parameters if possible #32

Open 0Lucifer0 opened 1 year ago

0Lucifer0 commented 1 year ago

Would be nice if the parameters that already exists were reused. I believe the only change required for this are to move away from IList to IList and use this in AppendRowsAsValues

    var parameter = value?.GetType().IsValueType == true ? parameters.FirstOrDefault(x => x.Value == value) : null;
                        var paramName = parameter?.ParameterName ?? $"{paramPattern}{i}";

                        if (parameter == null)
                        {
                            var param = command.CreateParameter();
                            param.ParameterName = paramName;
                            param.Value = value;
                            parameters.Add(param);
                            i++;
                        }

                        sb.Append(paramName);