Dav*_*Dev 7 .net sql vb.net orm entity-framework
我创建了一个包含常用变量的通用DLL.我有用户定义的字段作为占位符,因此我们可以保存客户特定的数据.此dll将用于客户端特定的应用程序.
如何将这些通用变量映射到相关的sql表字段,以便我们可以操作自定义数据库?我想避免编写自定义查询.
一个像小巧玲珑的ORM会在这里有用吗?
编辑:根据danihp的回应,我开始研究实体框架的工作.看起来很有希望.我推断使用Fluent API我可以将这个dll移植到独特的应用程序中并传递db对象(而不是我的类?)来做业务逻辑.
Public Class Runs
Private _RunMailPeices As Dictionary(Of String, MailPiece) = New Dictionary(Of String, MailPiece)
Private _run As Integer
Private MailDate As DateTime
Public Property RunMailPeices As Dictionary(Of String, MailPiece)
Get
RunMailPeices = _RunMailPeices
End Get
Set(value As Dictionary(Of String, MailPiece))
_RunMailPeices = value
End Set
End Property
Public Property run As Integer
Get
run = _run
End Get
Set(value As Integer)
_run = value
End Set
End Property
End Class
Run Code Online (Sandbox Code Playgroud)
和:
Public Class MailPiece
Private _address1 As String = String.Empty
Private _address2 As String = String.Empty
Private _string1 As String = String.Empty
Private _string2 As String = String.Empty
Public Property Address1 As String
Get
Address1 = _address1
End Get
Set(value As String)
_address1 = value
End Set
End Property
Public Property Address2 As String
Get
Address2 = _address2
End Get
Set(value As String)
_address2 = value
End Set
End Property
Public Property String1 As String
Get
String1 = _string1
End Get
Set(value As String)
_string1 = value
End Set
End Property
Public Property String2 As String
Get
String2 = _string2
End Get
Set(value As String)
_string2 = value
End Set
End Property
End Class
Run Code Online (Sandbox Code Playgroud)
您正在寻找实体框架.您可以轻松地将类映射到表.你只有两个相关的课程.将这些类映射到具有实体框架的表是如此容易.然后,您将避免编写查询,只是LINQ表达式和导航通过具有导航属性的表.
实体框架(EF)是一种对象关系映射器,它使.NET开发人员能够使用特定于域的对象处理关系数据.它消除了开发人员通常需要编写的大多数数据访问代码的需要.
通常创建数据访问层." 实体框架是微软推荐的新应用数据访问技术 "
您的代码看起来很容易被EF处理,但是,如果没有,您可以编写新的类来轻松地保留您的自定义类.
您可以使用VB.NET在Entity Framework Fluent API上通过示例EF VB.NET代码学习
归档时间: |
|
查看次数: |
237 次 |
最近记录: |