Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/270.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用sqlite pcl和通用存储库存储具有类属性的自动映射对象_C#_Xamarin_Sqlite Net Extensions - Fatal编程技术网

C# 使用sqlite pcl和通用存储库存储具有类属性的自动映射对象

C# 使用sqlite pcl和通用存储库存储具有类属性的自动映射对象,c#,xamarin,sqlite-net-extensions,C#,Xamarin,Sqlite Net Extensions,我正在从事的项目是一个Xamarin移动应用程序,带有RESTAPI和离线优先实践。 为了实现这一点,我设置了一个通用存储库,该存储库负责处理与设备上SQLite数据库的通信 Offline first仅用作读取数据的回退机制,不需要处理“复杂场景” 我们正在使用automapper将http json对象转换为域到数据库表,我们在存储数据库dto对象的类属性时遇到了问题 映射时,卸载和加载地址被正确转换,但sqlite似乎无法将地址解析为字符串 请参阅订单dto的地址和地址blob /

我正在从事的项目是一个Xamarin移动应用程序,带有RESTAPI和离线优先实践。 为了实现这一点,我设置了一个通用存储库,该存储库负责处理与设备上SQLite数据库的通信

Offline first仅用作读取数据的回退机制,不需要处理“复杂场景”

我们正在使用automapper将http json对象转换为域到数据库表,我们在存储数据库dto对象的类属性时遇到了问题

映射时,卸载和加载地址被正确转换,但sqlite似乎无法将地址解析为字符串

请参阅订单dto的地址和地址blob

    /// DTO Wrapper for storing order information do the database
    /// </summary>
    /// <seealso cref="CarrierConnectMobile.Core.Repositories.EntityBase" />
    [Table("Orders")]
    public class DTO_DBOrder : EntityBase
    {
        public string? LicensePlate { get; set; }
        public string Quantity { get; set; }
        public string ProductKind { get; set; }
        public string ProductType { get; set; }
        public string Product { get; set; }
        public OrderStatus Status { get; set; }
        public bool ProvidedUnloadData { get; set; }
        public bool ProvidedLoadData { get; set; }
        [TextBlob("UnLoadAddressBlob")]
        public DTO_DBAddress UnloadAddress { get; set; }
        [TextBlob("LoadAddressBlob")]
        public DTO_DBAddress LoadAddress { get; set; }

        public string UnLoadAddressBlob { get; set; }
        public string LoadAddressBlob { get; set; }
    }
///DTO用于存储订单信息的包装器在数据库中
/// 
/// 
[表(“订单”)]
公共类DTO_DBOrder:EntityBase
{
公共字符串?LicensePlate{get;set;}
公共字符串数量{get;set;}
公共字符串ProductKind{get;set;}
公共字符串ProductType{get;set;}
公共字符串乘积{get;set;}
公共订单状态状态{get;set;}
公共bool ProvidedUnloadData{get;set;}
public bool提供的加载数据{get;set;}
[TextBlob(“UnLoadAddressBlob”)]
公共数据to_DBAddress UnloadAddress{get;set;}
[TextBlob(“LoadAddressBlob”)]
公共数据地址LoadAddress{get;set;}
公共字符串UnloadaAddressBlob{get;set;}
公共字符串LoadAddressBlob{get;set;}
}
数据库的DTO对象的automapper配置文件对于UnloadaAddress和LoadAddress具有相同的命名约定,并且它们使用以下最小设置正确映射

public DBProfiles()
        {
            CreateMap<DTO_DBAddress, DTO_HttpAddress>().ReverseMap();
            CreateMap<DTO_DBAddress, Address>().ReverseMap();

            CreateMap<DTO_DBOrder, Order>()
                .ReverseMap();
            CreateMap<DTO_DBOrder, DTO_httpOrderListItem>()
                .ForMember(d => d.Status, opt => opt.ConvertUsing(new OrderStatusStringToEnumConverter(), src => src.Status))
                .ReverseMap();
        }
公共数据库配置文件()
{
CreateMap().ReverseMap();
CreateMap().ReverseMap();
CreateMap()
.ReverseMap();
CreateMap()
.ForMember(d=>d.Status,opt=>opt.ConvertUsing(neworderstatusstringtoenumconverter(),src=>src.Status))
.ReverseMap();
}

有什么配置错误吗?由于我似乎无法找到为什么sqlite没有将地址对象存储为字符串块并正确解析它

查看您的描述,我不确定您的问题是什么?@CherryBu MSFT我编辑了问题描述,我同意它太宽泛了,对不起!该问题与将对象从数据库DTO映射到数据库DTO,并将DTO_DBAddress对象存储为sqlite中的字符串blob有关在sqlite中存储DTO_DBAddress对象时是否遇到问题?什么是DTO_DBAddress?