Can we encapsulate the set and get properties for LINQ entities?

 Posted by ArticlesMaint on 9/29/2009 | Category: LINQ Interview questions | Views: 2592


You can define setter and getter functions which encapsulate the private properties.
 

[Table(Name = "Customer")]

public class clsCustomerEntityWithProperties
{
private int _CustomerId;
private string _CustomerCode;
private string _CustomerName;

[Column(DbType = "nvarchar(50)")]
public string CustomerCode
{
set
{
_CustomerCode = value;
}
get
{
return _CustomerCode;
}
}

[Column(DbType = "nvarchar(50)")]
public string CustomerName
{
set
{
_CustomerName = value;
}
get
{
return _CustomerName;
}
}

[Column(DbType = "int", IsPrimaryKey = true)]
public int CustomerId
{
set
{
_CustomerId = value;
}
get
{
return _CustomerId;
}
}
}


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Login to post response