locked
How to use aps.net Dynamic Data(System.Web.DynamicData) in web api? RRS feed

  • Question

  • User745141034 posted

    How to use aps.net Dynamic Data(System.Web.DynamicData) in web api?

    Friday, May 13, 2016 6:38 AM

All replies

  • User603616845 posted

    Hi,

    how to use dynamic data in web api?

    Just go through with this nice article where you will find about how to handle dynamic data with web api.

    hope this will help you.

    thanks

    Friday, May 13, 2016 7:17 AM
  • User745141034 posted

    Hi:

       How to use aps.net Dynamic Data(System.Web.DynamicData) in web api?

    Friday, May 13, 2016 7:31 AM
  • User-330204900 posted

    Hi zzdfc, what are you trying to achieve? Remember DD is a web forms technology MVC and Web API have their own Metadata model I believe.

    Friday, May 13, 2016 9:04 AM
  • User-330204900 posted

    Hi Das.Sandeep, that article is about the data type dynamic in c# and Dynamic Data as the Web Forms framework sorry.

    Friday, May 13, 2016 9:07 AM
  • User745141034 posted

    Hi sjnaughton:

           I want to use MetaTable、MetaColumn of Dynamic Data in web api.

    Friday, May 13, 2016 9:46 AM
  • User745141034 posted

    Hi zzdfc, what are you trying to achieve? Remember DD is a web forms technology MVC and Web API have their own Metadata model I believe.

     I register two MetaModels to same a database,one MetaModel for web site,the other for web api.

    Friday, May 13, 2016 9:48 AM
  • User-330204900 posted

    you would be able to manually read the metamodel in web api but there is nothing to automatically implement the metadata like it does in DD in WebAPI sorry

    Friday, May 13, 2016 10:38 AM
  • User-330204900 posted

    I have never used WebAPI or MVC much but I don know that there is a MetaModel implementation in MVC and WebAPI you should research that I think.

    Friday, May 13, 2016 10:44 AM
  • User745141034 posted

    you would be able to manually read the metamodel in web api but there is nothing to automatically implement the metadata like it does in DD in WebAPI sorry

    case 1

     I register first MetaModel successfully in web api,then It throw exception when I register second MetaModel in web site.

    case 2

     I register first MetaModel successfully in web site,then It throw exception when I register second MetaModel in web api.

    Friday, May 13, 2016 12:18 PM
  • User745141034 posted

    I want get all columns of the table through MetaTable.Columns,.

    Can Entity Framework get all columns of the table?

    Friday, May 13, 2016 12:31 PM
  • User-330204900 posted

    I'm no expert on WebAPI but I was told that MVC had its own MetaModel which should be shared with WebAPI. but if you are just working with the MetaModel and the columns property you just need to add the code from the Global.asax in the default DD project to the appropriate start-up class in WebAPI then you should be able to reference it.

    You can get column info from EF but you would need to use reflection and that may hurt if you use it a lot.

    Friday, May 13, 2016 12:47 PM
  • User-330204900 posted

    in fact zzdfc, if you post a sample project and e-mail it to me at steve AT notaclue.net I'll be happy to look at it and get the MetaModel working for you.

    Friday, May 13, 2016 12:49 PM
  • User745141034 posted

    Hi sjnaughton:

          How to judge if the DBContext has registered before calling MetaModel.RegisterContext?

    How to get MetaModel instance that  DBContext had registered?

    Sunday, May 15, 2016 1:31 AM
  • User-330204900 posted

    you could try registering the MetaModel in something like the oncontextcreated event?

    Sunday, May 15, 2016 2:56 PM
  • User36583972 posted

    Hi zzdfc,

    I want get all columns of the table through MetaTable.Columns,.

    Can Entity Framework get all columns of the table?

    I suggest you can try to use EF to implement your needs. You will get all columns of the table you defined and provide clear data for other sites.

    The following is a basic tutorial to build and consume RESTful services using ASP.Net Web API 2 and Entity Framework Code First approach. http://www.codeproject.com/Articles/821439/Getting-started-with-ASP-Net-Web-API-using-CodeF

    Best Regards,

    Yohann Lu

    Monday, May 16, 2016 10:54 AM
  • User745141034 posted

    Hi zzdfc,

    zzdfc

    I want get all columns of the table through MetaTable.Columns,.

    Can Entity Framework get all columns of the table?

    I suggest you can try to use EF to implement your needs. You will get all columns of the table you defined and provide clear data for other sites.

    The following is a basic tutorial to build and consume RESTful services using ASP.Net Web API 2 and Entity Framework Code First approach. http://www.codeproject.com/Articles/821439/Getting-started-with-ASP-Net-Web-API-using-CodeF

    Best Regards,

    Yohann Lu

    Hi Yohann Lu:

            How to get column infomation from Entity Framework,please?

    Tuesday, May 24, 2016 9:12 AM
  • User36583972 posted

    Hi zzdfc,

    You can try the following code.

    var names = typeof(TemplateQuestionInfo).GetProperties()
                            .Select(property => property.Name)
                            .ToArray();
    
    
    
        class TemplateQuestionInfo
        {
          public   int QuestionID { get; set; }
            public string title { get; set; }
        }
    

    Best Regards,

    Yohann Lu

    Tuesday, May 24, 2016 10:53 AM