public class Enterprise : AuditedAggregateRoot<string>
{
public string Name { get; set; }
public string AbbreviationName { get; set; }
public IList<Operator> Operators => new List<Operator>();
[DisableAuditing]
public PointF Coordinates { get; set; }
public virtual void AddOperatorDevice([NotNull] Operator addOperator)
{
Check.NotNull(addOperator, nameof(addOperator));
var operatorItem = Operators.First(p => p.OperatorType == addOperator.OperatorType);
if (operatorItem == null)
{
Operators.Add(addOperator);
return;
}
foreach (var deviceId in addOperator.DeviceIds)
{
operatorItem.AddDeviceId(deviceId);
}
}
}
public enum OperatorType : byte
{
Telecom,
Cmcc,
Unicom,
Autarky
}
public class Operator : Entity<OperatorType>
{
public OperatorType OperatorType { get; set; }
public string Name { get; set; }
public IList<string> DeviceIds => new List<string>();
public virtual void AddDeviceId(string deviceId)
{
DeviceIds.Add(deviceId);
}
public virtual void RemoveDeviceId(string deviceId)
{
DeviceIds.Remove(deviceId);
}
}
AddOperatorDevice need check addOperator.OperatorType have added,if there are two threads post at the same time use EnterpriseAppService ,does this make threads unsafe? such as get operatorItem null all, abp.vNext framework ensure thread safe or need ensure by developer self?this confuses me.I use mongodb as persistence锛宼here is no abp sample like embedding document
This is not related to the framework, however;
@hikalkan thanks,such as conventional controllers,api can be use by many client,is it ensure domain accessed by only one thread at a time?
If you follow normal development, it is already ensured single thread/request access to an entity.
However, there is no nice way of making a class thread-safe by convention without designing the class itself thread-safe. So, will never work on this issue.
@hikalkan thank you, I follow normal development,if it is already ensured single thread/request access to an entity.I have no doubts.
Most helpful comment
This is not related to the framework, however;