I'm currently struggeling with a EntitySet
Code: Select all
CREATE TABLE `a` (
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`name` varchar(256) NULL DEFAULT NULL
);
CREATE TABLE `b` (
`id` INT(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
`a_id` INT(11) NULL DEFAULT NULL,
`name` varchar(256),
CONSTRAINT `FK` FOREIGN KEY (`a_id`) REFERENCES `a` (`id`)
)
Code: Select all
Protected Property bList As EntitySet(Of b)
Get
Return Session("bList")
End Get
Set(value As EntitySet(Of b))
Session("bList") = value
End Set
End Property
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim db = New DbContext()
var Current = db.a.SingleOrDefault(Function(x) x.Id = CurrentRequest.Id)
bList = Current.b
End Sub
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click, btnSaveAndNew.Click
Dim db = New DbContext()
Current = db.a.SingleOrDefault(Function(x) x.Id = CurrentRequest.Id)
Current.b = bList
db.SubmitChanges()
End Sub
Code: Select all
UPDATE b SET a_id = :p1 WHERE id = :key1
-- p1: Input Int (Size = 0; DbType = Int32) []
-- key1: Input Int (Size = 0; DbType = Int32) [33495]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Mapping: AttributeMappingSource Build: 4.2.327.0
INSERT INTO b (a_id) VALUES (:p1)
-- p1: Input Int (Size = 0; DbType = Int32) [12749]
-- Context: Devart.Data.MySql.Linq.Provider.MySqlDataProvider Mapping: AttributeMappingSource Build: 4.2.327.0
Thanks for help!