Esempio n. 1
0
        public static int InsertCompany(String name, String adresse, String tel)
        {
            bindedinEntities bie = SingletonEntities.Instance;
             var existingCompany = from s in bie.companies
                                  where s.nom.Equals(name)
                                  where s.adresse.Equals(adresse)
                                  where s.telephone.Equals(tel)
                                  select s;

             if (existingCompany.Count() == 0)
             {

                 company sc = new company
                 {
                     nom = name,
                     adresse = adresse,
                     telephone=tel,
                 };
                 bie.companies.AddObject(sc);
                 bie.SaveChanges();

             }
            var id = from s in bie.companies
                     where s.nom.Equals(name)
                     where s.adresse.Equals(adresse)
                     where s.telephone.Equals(tel)
                     select s.id;
            return id.First();
        }
 /// <summary>
 /// Deprecated Method for adding a new object to the companies EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddTocompanies(company company)
 {
     base.AddObject("companies", company);
 }
 /// <summary>
 /// Create a new company object.
 /// </summary>
 /// <param name="id">Initial value of the id property.</param>
 /// <param name="nom">Initial value of the nom property.</param>
 public static company Createcompany(global::System.Int32 id, global::System.String nom)
 {
     company company = new company();
     company.id = id;
     company.nom = nom;
     return company;
 }