EntityFramework

EF添加数据后返回添加的自增ID

public int InsertSingle(SDTI_VendorInfoEntity Ven)
        {
            db.Entry<SDTI_VendorInfoEntity>(Ven).State = System.Data.Entity.EntityState.Added;
            db.SaveChanges();
            return Ven.V_Vendor_ID;
        }
public int InsertSingle(SDTI_VendorInfoEntity ven)
        {
            try
            {
                int b = vendor.InsertSingle(ven);
                int x = ven.V_Vendor_ID;
                return 1;
            }
            catch (Exception e)
            {
                return 0;
            }

        }

 

posted @ 2017-10-26 15:03  XinYiBuFang  阅读(127)  评论(0编辑  收藏  举报