none
Working with entity types name RRS feed

  • Question

  • Hello !

    Normally , when I add a new object I write : context.MySubjects.add (NewSubject)

    But , I have a situation when I have the name "MySubjects" in a string variable called Ename

    In this case , is there any way to add the new object using the Ename variable ?

    Thank you !

    Saturday, October 11, 2014 5:35 PM

Answers

  • Hi,

    Unfortunately, the current Entity Framework does not support this behavior.

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, October 14, 2014 2:35 AM
    Moderator

All replies

  • Hello dcode25,

    >>But , I have a situation when I have the name "MySubjects" in a string variable called Ename

    If you mean below situation:

    string EName = "MySubjects";
    
    db.MySubjects.Add(Ename);
    

    No, this is not possible. The DbSet class does not provide the Add() method which could accept a string variable.

    If I do not understand correctly, please let me know and please provide some code which could clarify your requirement.

    Regards,

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, October 13, 2014 6:30 AM
    Moderator
  • No , I mean something like this :

    context.entity(ename).add(NewSubject) 

    Monday, October 13, 2014 1:59 PM
  • Hi,

    Unfortunately, the current Entity Framework does not support this behavior.

    Fred.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    Tuesday, October 14, 2014 2:35 AM
    Moderator