locked
field is required in ria service in lightswitch RRS feed

  • Question

  • I have a lightswitch application with an external  SQL server database, I created a RIA service project to extract the data from the database.

    In one table (Called OrderDetail), I have shippedDate and PaidDate both of them are of type of datetime and are NOT REQUIRED.

    I added the RIA service project  to the Lightswitch solution:

    public class OrdersDetails
        {
         
            [Key]
            public int DetailOrderID { get; set; }
            public int OrderID { get; set; }
            public DateTime ShippedDate { get; set; }
            public DateTime PaidDate { get; set; }
            public string InvoiceNumber { get; set; }
            public decimal SalesAmount { get; set; }
         }

    then when I added WCF RIA Service to the Data Source of the lightswitch project,

    I noticed that the two fields showed up required in the entity OrdersDetails even they're required in SQL server database.

    What am I missing? I need these two fields NOT REQUIRED.

    How can I change them back to NOT REQUIRED?

    Thanks,

    Rachida


    Rachida Dukes

    Saturday, December 8, 2012 12:57 AM

Answers

  • You need to make your properties to be of type DateTime? (or using the syntax Nullable<DateTime>), instead of just DateTime.

    public class OrdersDetails
         {
           
            [Key]
             public int DetailOrderID { get; set; }
             public int OrderID { get; set; }
             public DateTime? ShippedDate { get; set; }
             public DateTime? PaidDate { get; set; }
             public string InvoiceNumber { get; set; }
             public decimal SalesAmount { get; set; }
          }


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Rachida Saturday, December 8, 2012 12:26 PM
    Saturday, December 8, 2012 10:59 AM
    Moderator

All replies

  • You need to make your properties to be of type DateTime? (or using the syntax Nullable<DateTime>), instead of just DateTime.

    public class OrdersDetails
         {
           
            [Key]
             public int DetailOrderID { get; set; }
             public int OrderID { get; set; }
             public DateTime? ShippedDate { get; set; }
             public DateTime? PaidDate { get; set; }
             public string InvoiceNumber { get; set; }
             public decimal SalesAmount { get; set; }
          }


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Rachida Saturday, December 8, 2012 12:26 PM
    Saturday, December 8, 2012 10:59 AM
    Moderator
  • Thanks Yann for saving me again, your response works perfectely.

    Have a nice week end.

    Rachida


    Rachida Dukes

    Saturday, December 8, 2012 12:26 PM
  • Thank you, & you're welcome..

    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    Saturday, December 8, 2012 4:14 PM
    Moderator