Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WCFC#4.0
In IService.cs file, I have created 2 classes.
[ServiceContract]
    public interface IService1
    {
 
    }
 
    [DataContract]
    public class CLSReportMenu
    {
        int _reportID = 0;
        string _reportName = string.Empty;
 
        int _parentID = 0;
 
        [DataMember]
        public int ReportID
        {
            get { return _reportID; }
            set { _reportID = value; }
        }
 
        [DataMember]
        public string ReportName
        {
            get { return _reportName; }
            set { _reportName = value; }
        }
 
        [DataMember]
        public int ParentID
        {
            get { return _parentID; }
            set { _parentID = value; }
        }
 
        public CLSReportMenu(string reportname)
        {
            ReportName = reportname;
        }
 
    }
 
    [DataContract]
    public class ReportHierarchy
    {
        public ReportHierarchy()
        {
        }
 
        [DataMember]
        public DataTable ReportRecord
        {
            get;
            set;
        }
 
        [DataMember]
        public CLSReportMenu objreport { get; set; }
        [DataMember]
        public List<ReportHierarchy> Children { get; set; }
 
        public ReportHierarchy(CLSReportMenu report)
        {
            objreport = report;
            Children = new List<ReportHierarchy>();
        }
 
    }
Now I would like to access the Constructors "public ReportHierarchy(CLSReportMenu report)" from ReportHierarchy class and "public CLSReportMenu(string reportname)" from CLSReportMenu class under Datacontract. I just want to access the logic inside both the constructors. The logic that I am building is Parent & child Hierarchy that I will using to build menu when I am able to access those constructors on my client application.
 
Looking for some help.
 
Regards
Vasavi
Posted 14-Nov-12 22:57pm
Edited 14-Nov-12 23:10pm
v2
Comments
Sergey Alexandrovich Kryukov at 15-Nov-12 13:59pm
   
What logic inside? I cannot see any logic in your code sample. Data Contract is based on the use of parameterless constructors. It's absolutely not clear what do you mean by "access", and "access from data contract". Now, hierarchy (tree structure of relationship) is the simplest case for Data Contract, something which always works automatically. You probably don't quite understand what Data Contract does. In brief, you create some arbitrary object graph and persist it. When you read the previously stored data, Data Contract serializers simply restore the object graph exactly to the same logical state as it was before, but the mechanism takes into consideration only [DataMember] members. That's it -- a hierarchy is not a problem at all. --SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 Shai Vashdi 458
1 Tadit Dash 300
2 Sergey Alexandrovich Kryukov 250
3 OriginalGriff 173
4 Peter Leow 130
0 Sergey Alexandrovich Kryukov 9,435
1 OriginalGriff 5,498
2 Peter Leow 4,230
3 Maciej Los 3,540
4 Abhinav S 3,353


Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 15 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Use
Layout: fixed | fluid