public static int InsertOrUpdateT_WQX_REF_TAXA_ORG(global::System.String bIO_SUBJECT_TAXAONOMY, global::System.String oRG_NAME, global::System.String cREATE_USER_ID) { using (OpenEnvironmentEntities ctx = new OpenEnvironmentEntities()) { try { Boolean insInd = true; T_WQX_REF_TAXA_ORG a = new T_WQX_REF_TAXA_ORG(); if (ctx.T_WQX_REF_TAXA_ORG.Any(o => o.BIO_SUBJECT_TAXONOMY == bIO_SUBJECT_TAXAONOMY && o.ORG_ID == oRG_NAME)) { //update case a = (from c in ctx.T_WQX_REF_TAXA_ORG where c.BIO_SUBJECT_TAXONOMY == bIO_SUBJECT_TAXAONOMY && c.ORG_ID == oRG_NAME select c).FirstOrDefault(); insInd = false; } a.BIO_SUBJECT_TAXONOMY = bIO_SUBJECT_TAXAONOMY; a.ORG_ID = oRG_NAME; if (insInd) //insert case { a.CREATE_DT = System.DateTime.Now; a.CREATE_USERID = cREATE_USER_ID; ctx.AddToT_WQX_REF_TAXA_ORG(a); } ctx.SaveChanges(); return 1; } catch (Exception ex) { return 0; } } }