Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Program
- {
- static Model1 d = new Model1();
- static void Main(string[] args)
- {
- save(); // 1 //success
- save(); // 2 //error
- save("xxx"); //3 //why this got error?, when i check Sql Server Profiler, query same with No 2, error duplicate, it should not be error, because the id is not the same
- }
- private static void save(string id="zzz")
- {
- try
- {
- d.Cage.Add(new Cage()
- {
- CageId = id, // id cant same
- CreatedOn = DateTime.Now,
- UpdatedOn = DateTime.Now,
- Depreciation = 0
- });
- d.SaveChanges();
- }
- catch (Exception)
- {
- Console.WriteLine("Error");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement