Всем доброго времени суток!
Столкнулся с такой проблемой, валятся ошибки при использовании ATF.Repository объектной модели и выгрузке данных в список:
[Schema("Account")]
public class Account : BaseModel
{
[SchemaProperty("Name")]
public string Name { get; set; }
[DetailProperty("Account")]
public virtual List<AccountWorkingTime> WorkingTimes { get; set; }
}
[Schema("AbWorkingTimeStation")]
public class AccountWorkingTime : BaseModel
{
[SchemaProperty("Account")]
public Guid AccountId { get; set; }
[LookupProperty("DayOfWeek")]
public virtual DayOfWeek DayOfWeek { get; set; }
[SchemaProperty("From")]
public DateTime From { get; set; }
[SchemaProperty("To")]
public DateTime To { get; set; }
}
namespace PlatformIntegration.Files.cs
{
[DefaultBinding(typeof(IAccountAdapter))]
public class AccountAdapter : IAccountAdapter
{
public UserConnection UserConnection { get; set; }
public AccountAdapter(UserConnection userConnection)
{
UserConnection = userConnection;
}
private IRepository _repository;
private IRepository Repository
{
get => _repository ??= new Repository
{UserConnection = UserConnection, UseAdminRight = false};
set => _repository = value;
}
public Models.Account GetAccountById(Guid id)
{
var account = Repository.GetItem<Models.Account>(id);
return account;
}
}
}
При отработке метода GetAccountById - вылазят ошибки https://prnt.sc/uh1zso
Terrasoft.Web.Common.ServiceModel.ErrorHandler HandleError - Error getting value from 'WorkingTimes' on 'Castle.Proxies.AccountProxy'.
Newtonsoft.Json.JsonSerializationException: Error getting value from 'WorkingTimes' on 'Castle.Proxies.AccountProxy'. ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение. ---> System.InvalidCastException: Объект должен реализовывать интерфейс IConvertible.
в System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
в ATF.Repository.Repository.FillPropertyValue[T](T model, PropertyInfo propertyInfo, Object value)
в ATF.Repository.Repository.FillPropertyValues[T](T model, IDictionary`2 values)
в ATF.Repository.Repository.CreateItem[T](IDictionary`2 values)
в ATF.Repository.Repository.LoadModelByValues[T](IDictionary`2 values)
в ATF.Repository.Repository.<>c__DisplayClass64_0`1.b__0(IDictionary`2 recordValues)
в System.Collections.Generic.List`1.ForEach(Action`1 action)
в ATF.Repository.Repository.GetItems[T](String filterPropertyName, Guid filterValue)
--- Конец трассировки внутреннего стека исключений ---
в System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
в System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
в System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
в System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
в ATF.Repository.Repository.FillDetailValue[T](T model, ModelItem detail)
в ATF.Repository.Builder.InstanceProxyHelper`1.FillProperty(IInvocation invocation, PropertyInfo property)
в ATF.Repository.Builder.InstanceProxyHelper`1.InternalGet(IInvocation invocation, PropertyInfo property)
в ATF.Repository.Builder.InstanceProxyHelper`1.Intercept(IInvocation invocation)
в Castle.DynamicProxy.AbstractInvocation.Proceed()
в Castle.Proxies.AccountProxy.get_WorkingTimes()
в GetWorkingTimes(Object )
в Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
--- Конец трассировки внутреннего стека исключений ---
в Newtonsoft.Json.Serialization.DynamicValueProvider.GetValue(Object target)
в Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.CalculatePropertyValues(JsonWriter writer, Object value, JsonContainerContract contract, JsonProperty member, JsonProperty property, JsonContract& memberContract, Object& memberValue)
в Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty)
в Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType)
в Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType)
в Newtonsoft.Json.JsonConvert.SerializeObjectInternal(Object value, Type type, JsonSerializer jsonSerializer)
в Newtonsoft.Json.JsonConvert.SerializeObject(Object value)
в AutobookingPlatformIntegration.AccountIntegrationService.GetAccountById(Guid id)
в SyncInvokeGetAccountById(Object , Object[] , Object[] )
в System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
в System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc& rpc)
в System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc& rpc)
в System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc& rpc)
в System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
Кто нибудь сталкивался с таким поведением?