This is a migrated thread and some comments may be shown as answers.

Null Values for fields

2 Answers 132 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Santhosh
Top achievements
Rank 1
Santhosh asked on 29 Sep 2009, 12:35 PM
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 Answers, 1 is accepted

Sort by
0
IT-Als
Top achievements
Rank 1
answered on 29 Sep 2009, 01:22 PM
Hi Santosh,

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

for example

private Nullable<DateTime> startDate;

Regards

Henrik
0
PetarP
Telerik team
answered on 29 Sep 2009, 06:25 PM
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.
Tags
Databases and Data Types
Asked by
Santhosh
Top achievements
Rank 1
Answers by
IT-Als
Top achievements
Rank 1
PetarP
Telerik team
Share this question
or