Chan,
If I understand you, you are asking if you can store something to the database, but not using the underlying DataTable that the BO uses within a custom property. If this is what you mean...
I've done this many times. In the set statement of the property, just use the ExecuteNonQuery() of the BO to execute any command on db that is needed. In the get statement of the property, use ExecuteScalar() (most likely) to get the value.
Here's a quick example (in VB):
Public Property ValueNotInBO() As String
Get
' if no data is returned from the db, return an empty string
Dim value As String = String.Empty
Using cmd As New SqlCommand()
' Here I'm assuming the PK of the BO, called bo_pk, is also the pk of TableNotUsedByBO
cmd.CommandText = "Select ValueNotInBO From TableNotUsedByBO Where pk = @pk"
cmd.Parameters.Add("@pk",Int)
cmd.Parameters("@pk").Value = Me.bo_pk
' It is possible that there is no match, in which case ret will be nothing
' It might also be possible that ret is NULL (based on db schema)
Dim ret As Object = Me.ExecuteScalar(cmd)
If ret IsNot Nothing AndAlso ret IsNot DBNull.Value Then
value = CType(ret,String)
End If
End Using
End Get
Set(value As String)
' In real code, you'd have to check if an insert or update was needed
' Here I'm just doing the insert.
Using cmd As New SqlCommand()
cmd.CommandText = "Insert Into TableNotUsedByBO (pk,ValueNotInBO) Value (@pk,@value)"
' Here I'm assuming the PK of the BO, called bo_pk, is also the pk of TableNotUsedByBO
cmd.Parameters.Add("@value",Int)
cmd.Parameters("@value").Value = value
cmd.Parameters.Add("@pk",Int)
cmd.Parameters("@pk").Value = Me.bo_pk
Dim ret As Object = Me.ExecuteScalar(cmd)
If ret IsNot Nothing AndAlso ret IsNot DBNull.Value Then
value = CType(ret,String)
End If
End Using
End Set
End Property
Hope this helps!