CS1929 C# 'RfcParameterClass' does not contain a definition for 'Cast' and the best extension method overload 'ParallelEnumerable.Cast(ParallelQuery)' requires a receiver of type 'ParallelQuery'
Hello everyone, I am making a method which works with SAP RFC connector. The connection works fine and I am able to get data from SAP easily but problem is with using this data. The CS1929 error causses the query on the bottom of the code. I would like to set a lot of "MLFBCode" instances from those data. Can anyone help me please? I am using VS 16.7.3 and .NET Core 3.1. Thank you a lot!
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using RFCCONNECTORLib;
using SmartLab_System.AppConfig;
using SmartLab_System.Models;
using RfcData = RFCCONNECTORLib.RfcParameterClass;
using RfcRow = RFCCONNECTORLib.RfcFields;
namespace SmartLab_System.Data
{
public static class RFCMethodsForSLS
{
private static NWRfcSession Session = new NWRfcSession();
//Info: https://rfcconnector.com/documentation/api/session/
public static bool WasConnected { get; private set; } = true;
public static Regex RegexPattern { get; private set; } = new Regex(Validation.MLFBLuke);
/// <summary>
/// Calls the "Connecting" method which returns wanted MLFB entries from SAP
/// </summary>
/// <param name="inputString">String which will be searched</param>
/// <param name="strLanguage">Set language "CS", "EN", "DE", ...</param>
/// <param name="maxRows">Set maximum returned rows count</param>
public static List<MLFBCode> GetMLFBData(string inputString, int maxRows = 100000, string strLanguage = "CS", string onlyIn4711 = "X")
{
string functionName = "/SIE/AD_ZPE_TL_MAT_INFO";
List<KeyValuePair<string, string>> inputParameters = new List<KeyValuePair<string, string>>();
List<string> outPutParameters = new List<string>();
inputParameters.Add(new KeyValuePair<string, string>("INPUT_STRING", inputString));
inputParameters.Add(new KeyValuePair<string, string>("LANG", strLanguage));
inputParameters.Add(new KeyValuePair<string, string>("ONLY_IN_4711", onlyIn4711));
outPutParameters.Add("MLFB"); // mlfb
outPutParameters.Add("MATNR"); // matnr (number)
outPutParameters.Add("MAKTG"); // text (description)
outPutParameters.Add("DEL_STAT"); // vymaz na urovni master dat - "X" means Deleted
outPutParameters.Add("DEL_STAT_WERK"); // vymaz na urovni zavodu - "X" means Deleted
outPutParameters.Add("DEL_DISPO_99"); // docasny vymaz na urovni disponenta - "X" means Deleted
outPutParameters.Add("DEL_STAT_LV"); // docasny vymaz statusem - "X" means Deleted
outPutParameters.Add("EXISTS_IN_4711"); // material zalozen pro nas zavod - "X" means was set for OEZ
RfcData data = (RfcData)Connecting(functionName, inputParameters);
List<MLFBCode> mLFBs = new List<MLFBCode>();
List<RFCOutputData> rFCOutputData = new List<RFCOutputData>();
mLFBs = (from RfcRow dataRow in data
select new MLFBCode()
{
MLFB = dataRow["MLFB"].ToString(),
Number = dataRow["MLFB"].ToString(),
Description = dataRow["MAKTG"].ToString(),
IdGroup = 1,
Active = true
}).ToList();
return mLFBs;
}
Editting question - For sure I add the Connecting(functionName, inputParameters) method code:
private static Object Connecting(string functionName, List<KeyValuePair<string, string>> inputParameters)
{
Regex regex = new Regex(Validation.MLFB);
Object data = new { };
string[,] resultTableArray = new string[,] { };
SetRFC(); //Set login data
if (!Session.IsConnected)
{
Session.Connect(); //Connection to SAP
if (Session.IsConnected)
{
FunctionCall fn = Session.ImportCall(functionName); //Set call
foreach (KeyValuePair<string, string> param in inputParameters) //Inserting input parametters of the SAP function
{
fn.Importing[param.Key].value = param.Value;
}
Session.CallFunction(fn, true); //Calling the function
data = fn.Tables["RESULT_TABLE"]; //Getting data from SAP
}
else WasConnected = false;
}
if (WasConnected)
Session.Disconnect();
return data;
}