Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: WCF C#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 23:57pm
Edited 15-Nov-12 0:10am
(no name)84.9K
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
0 OriginalGriff 539
1 Maciej Los 300
2 DamithSL 233
3 Sergey Alexandrovich Kryukov 209
4 BillWoodruff 200
0 OriginalGriff 7,168
1 Sergey Alexandrovich Kryukov 6,377
2 DamithSL 5,461
3 Manas Bhardwaj 4,876
4 Maciej Los 4,450


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

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100