- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是一名 C# 程序员,只能编写 VB.NET 代码。
在为我当前的客户进一步探索 NHibernate 时,我遇到了 FluentNHibernate,我觉得它非常有吸引力。
但是现在,我想知道如何将用于组件映射的 C# 代码“翻译”为 VB.NET 代码:
Component(x => x.Address, m =>
{
m.Map(x => x.Number);
m.Map(x => x.Street);
m.Map(x => x.PostCode);
});
Component(Of Client)(Function(c) c.Address, ...)
EDIT 1: Following Mr. JaredPar instructions, I figured that his solution might work. If we take the time to read his answer, we may notice that we both don't know what the MType is within his solution. I might have found out that the MType is:
FluentNHibernate.Mapping.ComponentPart(Of TComponent)
Thus, TComponent is, from my understanding, an anonymous type that I shall parameter to use. From this point of view, since I wish to map the properties of my Address object, replacing TComponent in my help method signature seems not to work.
Private Sub MapAdresseHelper(Of Adresse)(ByVal a As FluentNHibernate.Mapping.ComponentPart(Of Adresse))
a.Map(Function(m) m.Number)
a.Map(Function(m) m.Street).Length(50)
a.Map(Function(m) m.PostCode).Length(10)
End Sub
最佳答案
在 Visual Basic 2010 中,您可以编写以下内容
Component(Function(x) x.Address, Sub(m)
m.Map(Function(x) x.Number)
m.Map(Function(x) x.Street)
m.Map(Function(x) x.PostCode)
End Sub)
Private Sub Helper(ByVal m As MType)
m.Map(Function(x) x.Number)
m.Map(Function(x) x.Street)
m.Map(Function(x) x.PostCode)
End Sub
...
Component(Function(x) x.Address, AddressOf Helper)
关于vb.net - 这个 C# FluentNHibernate 组件映射的等效 VB.NET 代码是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2201511/
我正在使用 Team City 进行持续集成,用于 .Net 4 ASP MVC 3 应用程序。 在我的开发机器上,我可以构建和运行我的应用程序,但在构建服务器上我收到以下错误: ASPNETCOM
我有以下实体 我试图在 FluentNHibernate 的帮助下映射它们。 关于实体的一些说明: 属性 CreatedBy和 AssignedTo在 Task实体是 Person 类型,在数据库端是
我有一个名为权限的枚举。可以为用户分配权限,也可以为角色分配权限,然后为用户分配角色。 User 和 Role 都有这样的属性: public virtual IList Permissions {
有没有一种简单的方法为所有生成的表名加上字符串前缀? 惯例 Table.Is(x => "Prefix" + x.EntityType.Name) 仅适用于实体表(不适用于联接表或子类表) 我似乎找不
给定一个 Vehicle 类和一个 VehicleProperty 类... public class Vehicle { public virtual int Id { get; prote
出于某种原因,我无法正确完成此查询,而且我不明白为什么... 我有一个名为“博客”的对象,它有一个 ID 和一个“标签”列表。 每个“标签”都有一个 ID 和一个“名称”属性。 由于这是多对多关系,我
我有一个简单的 Fluent-NHibernate 映射让我很头疼!我正在尝试为其中一个实体映射字典,但它的 FK 仍然为空。 这是实体代码: public class Person { pu
我对 FluentNhibernate 公式映射有疑问。我需要在公式中使用联接表中的一列。 问题在以下三个表中得到证明:City, Person, Address class Person {
我有一个非常简单的数据库表,它以多对多关系连接另外两个表。 (几乎是将用户加入到问题中——想想书签) 此表的 NHibernate 实体如下所示: public class UserToRequest
我尝试通过使用多个 .Mappings 扩展调用手动添加映射类,但它似乎只包括最后一个。那么如何添加几个选定的类映射或多个程序集呢? 我的流畅配置通常如下所示: Return Fluently.Co
好的,所以昨天我设法获得了 NHibernate 和 FluentNHibernate 的最新主干版本,以用于我最新的小项目。 (我正在开发一个错误跟踪应用程序。)我使用 Repository 模式创
我遇到了 FluentNHibernate 的问题,希望有人可以帮助我。 我在名为 CampaignAreas 和 CampaignProducts 的两个类之间存在多对多关系。遗憾的是,Fluent
在我的应用程序中,我经常使用 FluentNHibernate。不幸的是,a Visual Studio Bug has forced me to get a different FNH versio
使用 Fluent NHibernate 映射简单的 Dictionary 属性的最佳方法是什么? 最佳答案 public class PersistedData { public virtu
我正在尝试使用 FluentNHibernate 创建与同一实体的关系,但不知道如何操作。有人成功了吗?你能帮帮我吗? 这是我的实体类: public class Menu { public
我有一个基类,其中包含一个名为 IsDirty 的属性。这是用于域模型的,不是数据库表中的列。 使用自动映射时,Fluent nhibernate 会尝试将此列添加到表中。解决此问题的一种方法是输入
我定义了以下数据库表: 俱乐部:身份证、姓名 成员:身份证、姓名 ClubMember: ClubId, MemberId 我定义了以下实体类: public class Club() {
我正在为尝试使用遗留数据库模式创建映射的当前场景而苦苦挣扎: 我有一对由组合键链接的父/子类,我正在使用 FluentNHibernate 创建它们之间的映射和关联。以下是类(class): /*Pa
FluentNHibernate 的自动映射是否支持通过约定创建多列唯一约束? 我可以轻松地创建单列唯一约束: public void Apply(IPropertyInstance instance
我正在将我的应用程序切换到 Postgresql,我的架构中的所有表都是小写的,当我使用 NHibernate 进行查询时,它会向映射中的表名添加双引号是 PascalCase 并导致查询失败,告诉我
我是一名优秀的程序员,十分优秀!