So today, I found some mysterious .NET architecture in the application I develop at work. I need 开发者_如何学Chelp in understanding this architecture. The person who wrote it is long gone and I'm stuck to figure it out. We are creating an object in some code from some random workflow in the web application (unimportant for my question). The object is being instantiated from a class found in a Designer.vb file. I couldn't initially see the file until I clicked the "show all files" in Solution Explorer in Visual Studio. There are 3 files linked together.. a *.xsd
file, a *.Designer.vb
file and a *.xsx
file. The *.Designer.vb
file looks to be auto-generated. Any guidance on how this architecture works and how I can change the SQL queries, would be appreciated.
Goal:
Getdbo.note.text
from the dbo.note
table column and place it in the dbo.exportnote.text
column. I just don't understand how it's connecting to the database and getting the data from the dbo.note.text
field. I want to make the query more specific (possibly put a where clause on it). But really I just want to understand how it's communicating with the database. Most of the code uses stored procedures. So I'm confused on the architecture. What would be really cool is if you can explain how this code was autogenerated. It appears that the *.xsd
file is an XML file when I "View in Browser" from the Solution Explorer.
Code to instantiate object of designer class:
Dim _TestResultsReportDataSet As New TestResultsReportDataSet
Image of Solution Explorer:
Snippet of partial class in designer:
<Global.System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "2.0.0.0"), _
Global.System.Serializable(), _
Global.System.ComponentModel.DesignerCategoryAttribute("code"), _
Global.System.ComponentModel.ToolboxItem(true), _
Global.System.Xml.Serialization.XmlSchemaProviderAttribute("GetTypedDataSetSchema"), _
Global.System.Xml.Serialization.XmlRootAttribute("TestResultsReportDataSet"), _
Global.System.ComponentModel.Design.HelpKeywordAttribute("vs.data.DataSet")> _
Partial Public Class TestResultsReportDataSet
Inherits Global.System.Data.DataSet
Call #1:
Dim filterString As String = String.Format("TestResultsReportId = {0}", _testResultsReportRow.TestResultsReportId)
Dim _noteRow As TestResultsReportDataSet.NoteRow
For Each _noteRow In _testResultsReportDataSet.Note.Select(filterString)
Dim _exportNote As New Exportnote(DataApplicationContext)
CopyNoteRowToExportNote(_exportNote, _noteRow, exportTestResultReportId)
_exportNote.Save()
Next
Call into "CopyNoteRowToExportNote":
Public Sub CopyNoteRowToExportNote(ByVal _exportNote As Exportnote, _
ByVal _NoteRow As TestResultsReportDataSet.NoteRow, _
ByVal exportTestResultReportId As Integer)
With _exportNote
.Exporttestresultreport.SetId(exportTestResultReportId)
.LabAccessioningNumber = _NoteRow.LabAccessioningNumber
.Text = _NoteRow.Text
End With
End Sub
... if you need more info, just ask
Strongly Typed DataSet was the answer. Although I still can't figure out how or where the SQL table's are mapped to a Strongly Typed DataSet DataTable created in the DataSet Designer when the DataTable is created manually, thus no TableAdaptor. That is one of my outstanding questions in my queue.
Yes this indeed is a Strongly Typed Dataset. You will find some .xsd files in the project for the dataset. The same dataset when opened in designer will have some (at least one) Data Adapters associated with it, and these will have a connection string stored with them. Typically the connection string they refer is from config file. So look for it.
Use of such strongly typed datasets makes it easier to do data inset/update/delete and select operations, as we can provide and verify table names and column names at compile time
精彩评论