none
Portable Class Library and DataTable attr

    Question

  • Using Portable Class Library for my Mobile Services data model seemed like a good idea, to ease development for different platforms. But when needing to tag classes with the DataTable attribute, I realised it wasn't so good of an idea.

    Is there any neat way to tag those classes defined in the PCL with the DataTable attrib, or am I doomed to have a "User" table instead of "users"? :(

    Wednesday, October 10, 2012 9:31 PM

Answers

  • You can also use the [DataContract] attribute (which AFAIK is part of the portable library subset) to customize the table name. That should work with the latest SDK.

        [DataContract(Name = "users")]
        public class User
        {
            [DataMember]
            public int Id { get; set; }
            [DataMember]
            public string Name { get; set; }
        }


    Carlos Figueira

    • Marked as answer by mobilemancer Saturday, October 13, 2012 9:27 PM
    Friday, October 12, 2012 11:07 PM
    Moderator

All replies

  • You can also use the [DataContract] attribute (which AFAIK is part of the portable library subset) to customize the table name. That should work with the latest SDK.

        [DataContract(Name = "users")]
        public class User
        {
            [DataMember]
            public int Id { get; set; }
            [DataMember]
            public string Name { get; set; }
        }


    Carlos Figueira

    • Marked as answer by mobilemancer Saturday, October 13, 2012 9:27 PM
    Friday, October 12, 2012 11:07 PM
    Moderator
  • Yeap, totally works with latest SDK.

    Thanks for the help! :)

    Saturday, October 13, 2012 9:28 PM