Null Values for fields

3 posts, 0 answers
  1. santhosh
    santhosh avatar
    28 posts
    Member since:
    Mar 2009

    Posted 29 Sep 2009 Link to this post

    hi all,

    I am using forward mapping, I am date field, in some cases i need to set the null value for that,

    How can specify this property using Openaccess.

    My Task Schema is 

    public class Tasks
        {
            public Tasks()
            {
                Assignee = new Resource();
                resource = new Resource();
                duration = 0;
                Edits = new List<TaskEdits>();
            }

            public Guid tuid = Guid.Empty;
            private string name = string.Empty;
            private string description = string.Empty;
            private Resource assignee;
            private Resource resource;
            private DateTime startDate = DateTime.MinValue;
            private int duration;
            private string project_name = string.Empty;
           
            [Telerik.OpenAccess.Depend()]
            public  IList<TaskEdits> edits = null;
            public string Name
            {
                get
                {
                    return name ;
                }
                set
                {
                    name = value;
                }
            }
            public string Description
            {
                get { return description; }
                set { description = value; }
            }
            public Resource Assignee
            {
                get
                {
                    return assignee;
                }
                set
                {
                   assignee = value;
                }
            }
            public DateTime StartDate
            {
                get
                {
                    return startDate;
                }
                set
                {
                    startDate = value;
                }
            }
            public int Duration
            {
                get { return duration; }
                set { duration = value; }
            }
            public Resource Resource
            {
                get { return resource; }
                set { resource = value; }
            }
            public string Project_Name
            {
                get{ return project_name;}
                set { project_name = value;}
            }
            public Guid TUID
            {
                get{ return tuid;}
                set { tuid = value; }
            }
            public IList<TaskEdits> Edits
            {
                get { return edits; }
                set { edits = value; }
            }
        }

     

    thanks in advance
  2. TSE
    TSE avatar
    381 posts
    Member since:
    Sep 2008

    Posted 29 Sep 2009 Link to this post

    Hi Santosh,

    You can declare the persistent field as a Nullable<DateTime>

    for example

    private Nullable<DateTime> startDate;

    Regards

    Henrik
  3. DevCraft banner
  4. PetarP
    Admin
    PetarP avatar
    754 posts

    Posted 29 Sep 2009 Link to this post

    Hi hgsdc,

    What Henrik provided is correct. You can as well put a question mark after the type of the field. This will mark it as nullable thus enabling you to insert nulls when ever you need to do so. Here is an example:
    private DateTime? startDate; 


    Regards,
    Petar
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Back to Top