var q = from a in db.Customers
from b in db.Employees
where a.City == b.City
select new
{
a.City,
b.Address
};
SELECT [t0].[City], [t1].[Address]
FROM [dbo].[Customers] AS [t0], [dbo].[Employees] AS [t1]
WHERE [t0].[City] = [t1].[City]
对于多表删除好像是一对多关系,参看这个:
Order与OrderDetail是一对多关系,首先DeleteOnSubmit其OrderDetail(多端),其次DeleteOnSubmit其Order(一端)。因为一端是主键。
var orderDetails =
from o in db.OrderDetails
where o.Order.CustomerID == "WARTH" && o.Order.EmployeeID == 3
select o;
var order =
(from o in db.Orders
where o.CustomerID == "WARTH" && o.EmployeeID == 3
select o).First();
foreach (OrderDetail od in orderDetails)
{
db.OrderDetails.DeleteOnSubmit(od);
}
db.Orders.DeleteOnSubmit(order);
db.SubmitChanges();
李永京
|
老鸟四级
|园豆:3114
|
2008-03-29 10:27