You may want your properties to be private set
so that they can't be changed from the outside:
public class Office
{
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
To do that you can make GetOffice a member of Office instead of OfficeRepository.
Or you can define a constructor ...
// Logically immutable
public class Office
{
public Office(Int32 SyncID, string OfficeName)
{
this.SyncID = SyncID;
this.OfficeName = OfficeName;
}
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
... and change your GetOffice method to invoke the constructor instead of invoking the set
properties.
Similarly, OfficeMgrViewModel needn't have a public set
property if it had a constructor.
See also this answer this answer which mentions how to simplify your GetOffice method to not use a List
, if you expect that your join where
will never produce more than one record.
You may want your properties to be private set
so that they can't be changed from the outside:
public class Office
{
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
To do that you can make GetOffice a member of Office instead of OfficeRepository.
Or you can define a constructor ...
// Logically immutable
public class Office
{
public Office(Int32 SyncID, string OfficeName)
{
this.SyncID = SyncID;
this.OfficeName = OfficeName;
}
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
... and change your GetOffice method to invoke the constructor instead of invoking the set
properties.
Similarly, OfficeMgrViewModel needn't have a public set
property if it had a constructor.
See also this answer which mentions how to simplify your GetOffice method to not use a List
, if you expect that your join where
will never produce more than one record.
You may want your properties to be private set
so that they can't be changed from the outside:
public class Office
{
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
To do that you can make GetOffice a member of Office instead of OfficeRepository.
Or you can define a constructor ...
// Logically immutable
public class Office
{
public Office(Int32 SyncID, string OfficeName)
{
this.SyncID = SyncID;
this.OfficeName = OfficeName;
}
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
... and change your GetOffice method to invoke the constructor instead of invoking the set
properties.
Similarly, OfficeMgrViewModel needn't have a public set
property if it had a constructor.
See also this answer which mentions how to simplify your GetOffice method to not use a List
, if you expect that your join where
will never produce more than one record.
You may want your properties to be private set
so that they can't be changed from the outside:
public class Office
{
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
To do that you can make GetOffice a member of Office instead of OfficeRepository.
Or you can define a constructor ...
// Logically immutable
public class Office
{
public Office(Int32 SyncID, string OfficeName)
{
this.SyncID = SyncID;
this.OfficeName = OfficeName;
}
public Int32 SyncID { get; private set; }
public string OfficeName { get; private set; }
}
... and change your GetOffice method to invoke the constructor instead of invoking the set
properties.
Similarly, OfficeMgrViewModel needn't have a public set
property if it had a constructor.
See also this answer which mentions how to simplify your GetOffice method to not use a List
, if you expect that your join where
will never produce more than one record.