OpenRobot.Framework.DynamicModel 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package OpenRobot.Framework.DynamicModel --version 1.1.0
                    
NuGet\Install-Package OpenRobot.Framework.DynamicModel -Version 1.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OpenRobot.Framework.DynamicModel" Version="1.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="OpenRobot.Framework.DynamicModel" Version="1.1.0" />
                    
Directory.Packages.props
<PackageReference Include="OpenRobot.Framework.DynamicModel" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add OpenRobot.Framework.DynamicModel --version 1.1.0
                    
#r "nuget: OpenRobot.Framework.DynamicModel, 1.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package OpenRobot.Framework.DynamicModel@1.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=OpenRobot.Framework.DynamicModel&version=1.1.0
                    
Install as a Cake Addin
#tool nuget:?package=OpenRobot.Framework.DynamicModel&version=1.1.0
                    
Install as a Cake Tool

OpenRobot.Framework.DynamicModel 使用说明

OpenRobot.Framework.DynamicModel 是一个 .NET 8.0 类库,用于在强类型 DTO 和动态属性模型之间进行双向转换。主要应用于数据模型的扁平化存储和恢复场景。

Architecture

核心转换方向

  1. Model → DynamicProperties: 通过 OpenModelToDynamicProperty.ModelToDynamicProperties() 将 DTO 实例转换为 OpenModel 集合(扁平化结构,便于数据库存储)

  2. DynamicProperties → Model: 通过 DynamicPropertyToModelFactory.DynamicPropertiesToModel<T>()OpenModel 集合转换回 DTO 实例

属性类型分类 (PropTypeFactory)

通过自定义特性标记属性类型:

  • [MainkeyAttribute] - 主键字段,使用 DynamicPropertyId
  • [KeyStringAttribute] - 需要 JSON 序列化的复杂类型
  • [PropIngoreAttribute] - 忽略转换
  • [CustomOpenConvertAttribute] - 自定义转换器

自动识别:

  • 基元类型 (string, int, DateTime 等)
  • 集合类型 (IEnumerable)
  • 自定义对象

关键类

  • OpenModel - 扁平化数据模型实现 IOpenModel
  • BaseApressTemplate - DTO 基类,提供 GetSingle()GetList() 方法访问源数据
  • IDynamicTemplateDto - DTO 标记接口
  • IDynamicPropEntity - 实体接口,用于 ORM 映射

Common Commands

# 构建
dotnet build

# Nuget 发布
dotnet pack
nuget push *.nupkg -Source https://api.nuget.org/v3/index.json

Usage Example

// DTO 定义
public class UserDto : IDynamicTemplateDto
{
    [Mainkey]
    public int Id { get; set; }

    [Description("用户名")]  // 显示标题
    public string Name { get; set; }

    [RegularExpression(@"^\d{6}$", ErrorMessage = "必须是6位数字")]  // 验证规则
    public string Code { get; set; }

    public AddressDto Address { get; set; }
    public List<PhoneDto> Phones { get; set; }
}

// Model -> DynamicProperties
var models = dto.ModelToDynamicProperties(mainId);

// DynamicProperties -> Model
var result = models.DynamicPropertiesToModel<UserDto>();

Nuget 发布

nuget push *.nupkg -Source https://api.nuget.org/v3/index.json
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on OpenRobot.Framework.DynamicModel:

Package Downloads
OpenRobot.Framework.FormControl

基于数据驱动的 WPF 动态表单构建与渲染引擎,支持 12 种控件类型、级联下拉、条件显示、跨字段校验和多列布局

OpenRobot.Framework.DynamicGeneralService

动态属性管理服务库,提供动态属性 CRUD 操作、实体与 DTO 双向转换、嵌套属性树管理

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.3.7 193 6/23/2026
1.3.6 117 6/16/2026
1.3.5 114 6/16/2026
1.3.4 105 5/24/2026
1.3.3 109 5/12/2026
1.3.2 109 5/11/2026
1.3.1 102 5/7/2026
1.3.0 101 5/6/2026
1.2.1 109 4/24/2026
1.2.0 138 4/16/2026
1.1.0 115 4/15/2026
1.0.0 119 4/13/2026