For my ASP.NET WebForms Azure application, I currently have 2 Models & I have couple of queries in respect to adding other 2 Models :
1) Both new models that I want to add have several fields in common. I am thinking OOPS style and wish to create a class/Model namely "CommonFields" and add an object of that in these 2 Models. The Code for it I am thinking should be :
public class Inquiry
{
public Inquiry()
{}
public string ClientId { get; set; }
public string ProjectName { get; set; }
public CommonFields Common_Fields { get; set; }
public string Status { get; set; }
public string Description { get; set; }
}
CommonFields contains just properties with respective tags like "Display", "Required", Validator, etc. I don't think the way I have added is the right way. I believe the way I am trying to add is not the right way. Searched alot for this, but couldn't get thru it.
2) In both these Models, I will need 1 or more fields of the existing models to populate in the dropbox in these models to create.
I couldn't get how to go thru this and make it work ! The 1st point is it possible. ASP supporting OOPS should be possible, can you tell how ?? Due to these queries am stuck and not able to create these Models. Please guide me.
Any help is highly appreciated.
Thanks
Alok SaxenaPosted Apr 9, 2015, 10:04 AM
For 1) Common - Use Interface
For 2) Create IList or simple Object properties.
public class Model1
{
public int M1Property1 { get; set; }
public int M1Property2 { get; set; }
}
public class Model2
{
public int M2Property1 { get; set; }
public int M2Property2 { get; set; }
}
public class Model3
{
#region Model3 Property
public int M3Property1 { get; set; }
public int M3Property2 { get; set; }
#endregion
#region IModel for common property
public string M34Property1 { get; set; }
public string M34Property2 { get; set; }
#endregion
#region Model1 Object
IList
#endregion
#region Model2 Object
IList
#endregion
}
public class Model4 : IModel34
{
#region Model4 Property
public int M4Property1 { get; set; }
public int M4Property2 { get; set; }
#endregion
#region IModel for common property
public string M34Property1 { get; set; }
public string M34Property2 { get; set; }
#endregion
#region Model1 Object
IList
#endregion
#region Model2 Object
IList
#endregion
}
public interface IModel34
{
string M34Property1 { get; set; }
string M34Property2 { get; set; }
}
Guest UserPosted Mar 16, 2015, 11:24 AM
public class BaseModel
{
public string Display { get; set; }
public string Required { get; set; }
}
public class Inquiry : BaseModel
{
public string ClientId { get; set; }
public string ProjectName { get; set; }
public string Status { get; set; }
public string Description { get; set; }
}