- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试将 DTO 对象映射到 CSLA.NET(请参阅: http://www.lhotka.net/cslanet/ )对象。为了解决这个问题,我使用了 Lhotka 随其框架提供的示例应用程序。下面是我正在使用的类的示例(为了清晰起见,我删除了大部分属性和方法):
<Serializable()> _
Public Class Project
Inherits BusinessBase(Of Project)
Private mId As Guid = Guid.NewGuid
Private mName As String = ""
Private mResources As ProjectResources = _
ProjectResources.NewProjectResources()
<System.ComponentModel.DataObjectField(True, True)> _
Public ReadOnly Property Id() As Guid
<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
Get
'CanReadProperty(True)
Return mId
End Get
End Property
Public Property Name() As String
<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
Get
'CanReadProperty(True)
Return mName
End Get
<System.Runtime.CompilerServices.MethodImpl(Runtime.CompilerServices.MethodImplOptions.NoInlining)> _
Set(ByVal Value As String)
'CanWriteProperty(True)
If Value Is Nothing Then Value = ""
If mName <> Value Then
mName = Value
PropertyHasChanged()
End If
End Set
End Property
Public ReadOnly Property Resources() As ProjectResources
Get
Return mResources
End Get
End Property
End Class
Public Class ProjectDTO
Private _id As Guid
Public Property Id() As Guid
Get
Return _id
End Get
Set(ByVal value As Guid)
_id = value
End Set
End Property
Private _name As String
Public Property Name() As String
Get
Return _name
End Get
Set(ByVal value As String)
_name = value
End Set
End Property
Private _resources As New List(Of ProjectResourceDTO)()
Public Property MyResources() As List(Of ProjectResourceDTO)
Get
Return _resources
End Get
Set(ByVal value As List(Of ProjectResourceDTO))
_resources = value
End Set
End Property
End Class
Mapper.CreateMap(Of ProjectDTO, Project)().ConstructUsing(Function(src As ProjectDTO) Project.NewProject())
Mapper.CreateMap(Of ProjectResourceDTO, ProjectResource)()
Mapper.CreateMap(Of ResourceDTO, Resource)()
我遇到的问题与资源只读属性的映射有关,该属性是从 BusinessListBase 继承的集合。将项目添加到此集合的唯一方法是执行方法Assign(resourceId)。
有人知道如何将 DTO 对象映射回 CSLA 对象吗? IE。我应该如何配置映射器?请注意,在这种特殊情况下,为 Resources 成员使用解析器没有帮助。
谢谢!
禅宗
最佳答案
Automapper 不会在这里为您提供帮助,因为它只能调用公共(public) API。
使用常规 CSLA.NET 编码来构建您的 ProjectResources
来自 DTO 的列表。加载每个 ProjectResource
时您应该调用LoadProperty<T>(IPropertyInfo pi, T value)
根据 CSLA 约定填充每个属性。
关于使用 Automapper 映射到 CSLA 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5654300/
什么是 CSLA 框架及其用途? 最佳答案 CSLA 是业务对象框架,允许您在数据层之上轻松创建业务对象。它允许您使用可靠的面向对象原则和良好的关注点分离来构建您的应用程序。 我强烈建议您阅读 Roc
哪个CSLA framework stereotype 应该与可编辑的演示网格一起使用吗? 最佳答案 通常,您将 BusinessListBase 用于任何可编辑的集合。我建议阅读 CSLA 书中有关
我是 CSLA 的新手,所以我想弄清楚如何解决以下问题。我想编写 4 个信息类,如下图所示。 它们都是信息类,DayRecordInfoCollection 是 DayRecordInfo 对象的集合
我的公司正在评估 CSLA.NET 作为我们所有 .NET 企业应用程序开发的可能标准框架。为了比较,有人可以推荐这个领域的一些替代框架吗? 最佳答案 我大体上同意 Neil 的观点。您还可以查看 W
我想快速学习 CSLA.NET。你有什么建议? 最佳答案 我建议下载 CSLA 源代码和示例(尤其是 ProjectTracker 示例)并查看代码。对我来说,快速学习一些东西的最好方法是构建一些东西
我们的系统使用基于 Entity Framework 的数据层。最近几个月,我们一直在使用 EF 生成的实体进行数据传输、业务逻辑和 UI。 由于我们的应用程序变得越来越大,我们决定创建一个单独的业务
关闭。这个问题是opinion-based .它目前不接受答案。 1年前关闭。 锁定。这个问题及其答案是locked因为这个问题是题外话,但具有历史意义。它目前不接受新的答案或交互。 我公司的主要 W
我有一个 CSLA 对象,它可以很好地从数据库返回数据,但是当我更改该对象上的任何属性时,该对象仍然显示 IsDirty =“false”。尽管当我创建一个新对象时它报告 IsDirty =“true
属性如下所示: private static PropertyInfo FooProperty= RegisterProperty(c => c.Foo, "Foo Friendly
我目前正在为我的公司研究和决定使用一种代码覆盖工具,到目前为止,我已经尝试过 NCover(Bolt 和 Desktop)、DotCover 和 NCrunch。到目前为止,我尝试过的所有工具都可以很
我正在阅读“Expert C# 2005 Business Objects”这本书。 本书描述了各种类继承的各种基类,以解决现实世界的问题。 但这本书并没有提供所有这些类的例子。 任何人都可以给我所有
我是 C#、csla 和 NHibernate 的新手。这可能是一个新手问题,但我在其他地方没有看到明确的解释。有人可以帮助我理解 之间的区别吗 public int Property
我正在尝试将 DTO 对象映射到 CSLA.NET(请参阅: http://www.lhotka.net/cslanet/ )对象。为了解决这个问题,我使用了 Lhotka 随其框架提供的示例应用程序
我们将致力于实现 Rocky Lhotka 的 CSLA 作为我们 Visual Studio 2008 解决方案的应用程序开发框架。我想在 SO 上试水,并且特别感兴趣的是开发人员对该方法与其他 O
我读过 CSLA 的几章书,我喜欢它,但最近更倾向于 Java,我正在寻找基于 Java 的等价物。有没有人知道任何接近 Java 中的 CSLA 的内容? 我也会接受其他现有技术的良好组合,以实现类
我们刚刚启动了一个新的 ASP.Net 项目,该项目使用 Web 服务将一些 CSLA 业务对象序列化为 JSON 数据,供我们的客户端 javascript/JQuery 代码使用。在客户端浏览器(
我最近在 http://forums.lhotka.net/ 上发布了这个,但我没有收到回复。希望我在这里有更好的运气。这是我的问题。 我正在使用 CSLA .NET 4.5,我最近向 Busines
我正在向我的 CSLA BusinessList 添加一个新项目。但我只能用 0 主键添加它,因为我添加的项目始终为空。如果我尝试: "Item temp= new item{...}"这个项目不是列
有没有人有 CSLA 中的单元测试示例。我发现很难用这个框架实现 TDD,想知道是否有任何简单的方法可以做到这一点。除了免费构建我的测试对象的 TypeMock Isolator 之外,还有其他我可以
我是 CSLA 的新手,我想了解 FieldManager.updatechildren(this) 与 FieldManager.updatechildren 之间的区别。什么时候适合使用其中任何一
我是一名优秀的程序员,十分优秀!