コード例 #1
0
ファイル: Organization.cs プロジェクト: chrisgundersen/bvcms
        public static OrganizationType FetchOrCreateType(CMSDataContext Db, string type)
        {
            var t = Db.OrganizationTypes.SingleOrDefault(pp => pp.Description == type);

            if (t == null)
            {
                var max = 10;
                if (Db.OrganizationTypes.Any())
                {
                    max = Db.OrganizationTypes.Max(mm => mm.Id) + 10;
                }
                t = new OrganizationType {
                    Description = type, Code = type.Substring(0, 3), Id = max
                };
                Db.OrganizationTypes.InsertOnSubmit(t);
                Db.SubmitChanges();
            }
            return(t);
        }
コード例 #2
0
ファイル: Organization.cs プロジェクト: alexserdyuk/bvcms
 public static OrganizationType FetchOrCreateType(CMSDataContext Db, string type)
 {
     var t = Db.OrganizationTypes.SingleOrDefault(pp => pp.Description == type);
     if (t == null)
     {
         var max = 10;
         if (Db.OrganizationTypes.Any())
             max = Db.OrganizationTypes.Max(mm => mm.Id) + 10;
         t = new OrganizationType { Description = type, Code = type.Substring(0, 3), Id = max };
         Db.OrganizationTypes.InsertOnSubmit(t);
         Db.SubmitChanges();
     }
     return t;
 }