I created a trigger for the table below in the sql server,
Buildings: ID decimal(24, 0) PK, Name varchar(255)
The trigger is
CREATE TRIGGER [dbo].[TRG_BLD]
ON [dbo].[Building]
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO Building (Name)
SELECT Name
FROM inserted
END
All it does, only inserting the row into the table (it does more, but I'm trying to simplify my case).
When I'm inserting a row from the sql server, everything is fine, but when I'm inserting through LinqToSql,
Building b = new Building();
b.Name = "building A";
DC.Buildings.InsertOnSubmit(b);
DC.SubmitChanges();
an exception occurs on 'SubmitChanges' saying :
An unhandled exception of type 'System.InvalidOperationException' occurred in System.Data.Linq.dll
Additional information: The null value cannot be assigned to a member with type System.Decimal which is a non-nullable value type.