R DataFrame object with WCF










0















I have a very vague understanding of WCF but after a bit of research I figured out that WCF does not like handling custom objects. I am looking for a feasible workaround.



This is my objective.
I aim to create a WCF service that accepts certain values from a client machine, sends them to the server where it invokes an R instance and executes a set of DataFrame transformations and return the resulting DataFrame. DataFrames seem to be in the format of a vector / 2D array.
The error I am getting is:
the operation is not supported in wcf because it uses type system.object



see example code below -



 public string R_to_SQLstring_InsertTable(string table_name, DataFrame Table)

string query2 = "INSERT INTO table_name (";

for (int x = 0; x < Table.ColumnCount; x++)

if (x == (Table.ColumnCount) - 1)

query2 = query2 + Table.Names[x] + "";

else

query2 = query2 + Table.Names[x] + ", ";



query2 = query2 + ") Values (";


for (int count1 = 0; count1 < Table.RowCount; count1++)

for (int count2 = 0; count2 < Table.ColumnCount; count2++)

if (count2 == (Table.ColumnCount) - 1)

query2 = query2 + " " + Table[count2][count1];

else

query2 = query2 + " " + Table[count2][count1] + ",";




if (count1 == (Table.RowCount) - 1)

query2 = query2 + ");";

else

query2 = query2 + "), (";



return query2;




public DataFrame R_Transformation_MergeTable(string tableloca1, string tableloca2)


StartupParameter rinit = new StartupParameter();
rinit.Quiet = true;
rinit.RHome = @"C:Program FilesRR-3.4.4";
rinit.Home = @"C:R";
REngine.SetEnvironmentVariables();
REngine engine = REngine.GetInstance(null, true, rinit);

try

engine.Evaluate("Table1 <- read.csv(file='" + tableloca1+")");
engine.Evaluate("Table2 <- read.csv(file='" + tableloca2 + ")");

DataFrame Table = engine.Evaluate("Merge <- merge(Table1,Table2)").AsDataFrame();
return Table;

catch (Exception x)


throw new Exception("Please Upload .CSV file");














share|improve this question


























    0















    I have a very vague understanding of WCF but after a bit of research I figured out that WCF does not like handling custom objects. I am looking for a feasible workaround.



    This is my objective.
    I aim to create a WCF service that accepts certain values from a client machine, sends them to the server where it invokes an R instance and executes a set of DataFrame transformations and return the resulting DataFrame. DataFrames seem to be in the format of a vector / 2D array.
    The error I am getting is:
    the operation is not supported in wcf because it uses type system.object



    see example code below -



     public string R_to_SQLstring_InsertTable(string table_name, DataFrame Table)

    string query2 = "INSERT INTO table_name (";

    for (int x = 0; x < Table.ColumnCount; x++)

    if (x == (Table.ColumnCount) - 1)

    query2 = query2 + Table.Names[x] + "";

    else

    query2 = query2 + Table.Names[x] + ", ";



    query2 = query2 + ") Values (";


    for (int count1 = 0; count1 < Table.RowCount; count1++)

    for (int count2 = 0; count2 < Table.ColumnCount; count2++)

    if (count2 == (Table.ColumnCount) - 1)

    query2 = query2 + " " + Table[count2][count1];

    else

    query2 = query2 + " " + Table[count2][count1] + ",";




    if (count1 == (Table.RowCount) - 1)

    query2 = query2 + ");";

    else

    query2 = query2 + "), (";



    return query2;




    public DataFrame R_Transformation_MergeTable(string tableloca1, string tableloca2)


    StartupParameter rinit = new StartupParameter();
    rinit.Quiet = true;
    rinit.RHome = @"C:Program FilesRR-3.4.4";
    rinit.Home = @"C:R";
    REngine.SetEnvironmentVariables();
    REngine engine = REngine.GetInstance(null, true, rinit);

    try

    engine.Evaluate("Table1 <- read.csv(file='" + tableloca1+")");
    engine.Evaluate("Table2 <- read.csv(file='" + tableloca2 + ")");

    DataFrame Table = engine.Evaluate("Merge <- merge(Table1,Table2)").AsDataFrame();
    return Table;

    catch (Exception x)


    throw new Exception("Please Upload .CSV file");














    share|improve this question
























      0












      0








      0








      I have a very vague understanding of WCF but after a bit of research I figured out that WCF does not like handling custom objects. I am looking for a feasible workaround.



      This is my objective.
      I aim to create a WCF service that accepts certain values from a client machine, sends them to the server where it invokes an R instance and executes a set of DataFrame transformations and return the resulting DataFrame. DataFrames seem to be in the format of a vector / 2D array.
      The error I am getting is:
      the operation is not supported in wcf because it uses type system.object



      see example code below -



       public string R_to_SQLstring_InsertTable(string table_name, DataFrame Table)

      string query2 = "INSERT INTO table_name (";

      for (int x = 0; x < Table.ColumnCount; x++)

      if (x == (Table.ColumnCount) - 1)

      query2 = query2 + Table.Names[x] + "";

      else

      query2 = query2 + Table.Names[x] + ", ";



      query2 = query2 + ") Values (";


      for (int count1 = 0; count1 < Table.RowCount; count1++)

      for (int count2 = 0; count2 < Table.ColumnCount; count2++)

      if (count2 == (Table.ColumnCount) - 1)

      query2 = query2 + " " + Table[count2][count1];

      else

      query2 = query2 + " " + Table[count2][count1] + ",";




      if (count1 == (Table.RowCount) - 1)

      query2 = query2 + ");";

      else

      query2 = query2 + "), (";



      return query2;




      public DataFrame R_Transformation_MergeTable(string tableloca1, string tableloca2)


      StartupParameter rinit = new StartupParameter();
      rinit.Quiet = true;
      rinit.RHome = @"C:Program FilesRR-3.4.4";
      rinit.Home = @"C:R";
      REngine.SetEnvironmentVariables();
      REngine engine = REngine.GetInstance(null, true, rinit);

      try

      engine.Evaluate("Table1 <- read.csv(file='" + tableloca1+")");
      engine.Evaluate("Table2 <- read.csv(file='" + tableloca2 + ")");

      DataFrame Table = engine.Evaluate("Merge <- merge(Table1,Table2)").AsDataFrame();
      return Table;

      catch (Exception x)


      throw new Exception("Please Upload .CSV file");














      share|improve this question














      I have a very vague understanding of WCF but after a bit of research I figured out that WCF does not like handling custom objects. I am looking for a feasible workaround.



      This is my objective.
      I aim to create a WCF service that accepts certain values from a client machine, sends them to the server where it invokes an R instance and executes a set of DataFrame transformations and return the resulting DataFrame. DataFrames seem to be in the format of a vector / 2D array.
      The error I am getting is:
      the operation is not supported in wcf because it uses type system.object



      see example code below -



       public string R_to_SQLstring_InsertTable(string table_name, DataFrame Table)

      string query2 = "INSERT INTO table_name (";

      for (int x = 0; x < Table.ColumnCount; x++)

      if (x == (Table.ColumnCount) - 1)

      query2 = query2 + Table.Names[x] + "";

      else

      query2 = query2 + Table.Names[x] + ", ";



      query2 = query2 + ") Values (";


      for (int count1 = 0; count1 < Table.RowCount; count1++)

      for (int count2 = 0; count2 < Table.ColumnCount; count2++)

      if (count2 == (Table.ColumnCount) - 1)

      query2 = query2 + " " + Table[count2][count1];

      else

      query2 = query2 + " " + Table[count2][count1] + ",";




      if (count1 == (Table.RowCount) - 1)

      query2 = query2 + ");";

      else

      query2 = query2 + "), (";



      return query2;




      public DataFrame R_Transformation_MergeTable(string tableloca1, string tableloca2)


      StartupParameter rinit = new StartupParameter();
      rinit.Quiet = true;
      rinit.RHome = @"C:Program FilesRR-3.4.4";
      rinit.Home = @"C:R";
      REngine.SetEnvironmentVariables();
      REngine engine = REngine.GetInstance(null, true, rinit);

      try

      engine.Evaluate("Table1 <- read.csv(file='" + tableloca1+")");
      engine.Evaluate("Table2 <- read.csv(file='" + tableloca2 + ")");

      DataFrame Table = engine.Evaluate("Merge <- merge(Table1,Table2)").AsDataFrame();
      return Table;

      catch (Exception x)


      throw new Exception("Please Upload .CSV file");











      c# r wcf rdotnet






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 14 '18 at 15:11









      Kale WilliamsKale Williams

      112




      112






















          1 Answer
          1






          active

          oldest

          votes


















          0














          I pass generic objects over WCF by manually serializing them to byte and passing in the type definition (as a string, Type cannot go over WCF either) then casting it back to the proper type using reflection. Given an object, you may have to iterate over it and use reflection to determine the type of each entry for this purpose though.



          A better technique if possible would be to cast the objects to a data contract type before sending them over the service.






          share|improve this answer























          • Could you provide an illustration ?

            – Kale Williams
            Nov 14 '18 at 15:41










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303316%2fr-dataframe-object-with-wcf%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          I pass generic objects over WCF by manually serializing them to byte and passing in the type definition (as a string, Type cannot go over WCF either) then casting it back to the proper type using reflection. Given an object, you may have to iterate over it and use reflection to determine the type of each entry for this purpose though.



          A better technique if possible would be to cast the objects to a data contract type before sending them over the service.






          share|improve this answer























          • Could you provide an illustration ?

            – Kale Williams
            Nov 14 '18 at 15:41















          0














          I pass generic objects over WCF by manually serializing them to byte and passing in the type definition (as a string, Type cannot go over WCF either) then casting it back to the proper type using reflection. Given an object, you may have to iterate over it and use reflection to determine the type of each entry for this purpose though.



          A better technique if possible would be to cast the objects to a data contract type before sending them over the service.






          share|improve this answer























          • Could you provide an illustration ?

            – Kale Williams
            Nov 14 '18 at 15:41













          0












          0








          0







          I pass generic objects over WCF by manually serializing them to byte and passing in the type definition (as a string, Type cannot go over WCF either) then casting it back to the proper type using reflection. Given an object, you may have to iterate over it and use reflection to determine the type of each entry for this purpose though.



          A better technique if possible would be to cast the objects to a data contract type before sending them over the service.






          share|improve this answer













          I pass generic objects over WCF by manually serializing them to byte and passing in the type definition (as a string, Type cannot go over WCF either) then casting it back to the proper type using reflection. Given an object, you may have to iterate over it and use reflection to determine the type of each entry for this purpose though.



          A better technique if possible would be to cast the objects to a data contract type before sending them over the service.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 14 '18 at 15:20









          Brandon BarkleyBrandon Barkley

          426312




          426312












          • Could you provide an illustration ?

            – Kale Williams
            Nov 14 '18 at 15:41

















          • Could you provide an illustration ?

            – Kale Williams
            Nov 14 '18 at 15:41
















          Could you provide an illustration ?

          – Kale Williams
          Nov 14 '18 at 15:41





          Could you provide an illustration ?

          – Kale Williams
          Nov 14 '18 at 15:41

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53303316%2fr-dataframe-object-with-wcf%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          ReactJS Fetched API data displays live - need Data displayed static

          政党