• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# CurtDevDataContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中CurtDevDataContext的典型用法代码示例。如果您正苦于以下问题:C# CurtDevDataContext类的具体用法?C# CurtDevDataContext怎么用?C# CurtDevDataContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CurtDevDataContext类属于命名空间,在下文中一共展示了CurtDevDataContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: AddImage

 public static string AddImage(int partID = 0, int sizeid = 0, string webfile = "", string localfile = "")
 {
     try {
         CurtDevDataContext db = new CurtDevDataContext();
         JavaScriptSerializer js = new JavaScriptSerializer();
         char sort = 'a';
         try {
             sort = db.PartImages.Where(x => x.partID.Equals(partID)).Where(x => x.sizeID.Equals(sizeid)).OrderByDescending(x => x.sort).Select(x => x.sort).First<char>();
             sort = GetNextLetter(sort.ToString());
         } catch {};
         System.Drawing.Image img = System.Drawing.Image.FromFile(localfile);
         PartImage image = new PartImage {
             partID = partID,
             sizeID = sizeid,
             path = webfile,
             height = img.Height,
             width = img.Width,
             sort = sort
         };
         img.Dispose();
         db.PartImages.InsertOnSubmit(image);
         db.SubmitChanges();
         return js.Serialize(image);
     } catch {
         return "error";
     }
 }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:27,代码来源:ImageModel.cs


示例2: GetCategories

        /// <summary>
        /// Retrieves a list of DetailedCategories objects
        /// </summary>
        /// <returns>List of DetailedCategories objects</returns>
        public static List<DetailedCategories> GetCategories()
        {
            List<DetailedCategories> cats = new List<DetailedCategories>();
            CurtDevDataContext db = new CurtDevDataContext();

            cats = (from c in db.Categories
                    select new DetailedCategories {
                        catID = c.catID,
                        dateAdded = c.dateAdded,
                        parentID = c.parentID,
                        parentCat = (from c2 in db.Categories where c2.catID.Equals(c.parentID) select c2.catTitle).FirstOrDefault<string>(),
                        catTitle = c.catTitle,
                        shortDesc = c.shortDesc,
                        longDesc = c.longDesc,
                        image = c.image,
                        isLifestyle = c.isLifestyle,
                        vehicleSpecific = c.vehicleSpecific,
                        partCount = (from p in db.Parts join cp in db.CatParts on p.partID equals cp.partID where cp.catID.Equals(c.catID) select p).Distinct().Count(),
                        content = (from cb in db.ContentBridges
                                   join co in db.Contents on cb.contentID equals co.contentID
                                   join ct in db.ContentTypes on co.cTypeID equals ct.cTypeID
                                   where cb.catID.Equals(c.catID)
                                   orderby co.cTypeID
                                   select new FullContent {
                                       content_type_id = co.cTypeID,
                                       content_type = ct.type,
                                       contentID = co.contentID,
                                       content = co.text
                                   }).ToList<FullContent>()
                    }).Distinct().OrderBy(x => x.catTitle).ToList<DetailedCategories>();

            return cats;
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:37,代码来源:ProductCatModels.cs


示例3: AddNews

        public ActionResult AddNews(int displayOrder = 0, string title = "", string pageContent = "", string subTitle = "", string isActive = "", string showDealers = "", string showPublic = "")
        {
            try {
                TechNews item = new TechNews();
                Boolean blnIsActive = false;
                blnIsActive = (isActive == "on") ? true : false;

                Boolean blnShowPublic = false;
                blnShowPublic = (showPublic == "on") ? true : false;

                Boolean blnShowDealers = false;
                blnShowDealers = (showDealers == "on") ? true : false;

                item.title = title;
                item.pageContent = pageContent;
                item.subTitle = subTitle;
                item.displayOrder = displayOrder;
                item.active = blnIsActive;
                item.showDealers = blnShowDealers;
                item.showPublic = blnShowPublic;
                item.dateModified = DateTime.Now;
                ViewBag.item = item;
                CurtDevDataContext db = new CurtDevDataContext();
                db.TechNews.InsertOnSubmit(item);
                db.SubmitChanges();
                return RedirectToAction("News", new { successMsg = "The news item was successfully added." });
            }

            catch (Exception e) {
                ViewBag.error = "Could not add news item: " + e.Message;
            }

            return View();
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:34,代码来源:TechServicesController.cs


示例4: generateCustomAPIKey

        public static void generateCustomAPIKey(Guid userID, List<string> selectedModuleIDs)
        {
            CurtDevDataContext db = new CurtDevDataContext();
            // create API Key with custom type
            ApiKey customKey = new ApiKey();
            customKey.id = Guid.NewGuid();
            customKey.api_key = Guid.NewGuid();
            customKey.type_id = db.ApiKeyTypes.Where(x => x.type == "Custom").Select(x => x.id).FirstOrDefault<Guid>();
            customKey.user_id = userID;
            customKey.date_added = DateTime.Now;

            db.ApiKeys.InsertOnSubmit(customKey);
            db.SubmitChanges();

            // create record for each selected module ID in the APIAcess table
            List<ApiAccess> listOfNewAPIAccesses = new List<ApiAccess>();
            foreach (string modID in selectedModuleIDs) {
                ApiAccess apiAccess = new ApiAccess();
                apiAccess.id = Guid.NewGuid();
                apiAccess.key_id = customKey.id;
                apiAccess.module_id = new Guid(modID);
                listOfNewAPIAccesses.Add(apiAccess);
            }
            db.ApiAccesses.InsertAllOnSubmit(listOfNewAPIAccesses);
            db.SubmitChanges();

            // submit changes
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:28,代码来源:UserManagement.cs


示例5: Get

        public static PostWithCategories Get(string date = "", string title = "")
        {
            try {
                DateTime post_date = Convert.ToDateTime(date);
                CurtDevDataContext db = new CurtDevDataContext();
                PostWithCategories post = new PostWithCategories();
                post = (from p in db.BlogPosts
                        where p.slug.Equals(title) && Convert.ToDateTime(p.publishedDate).Day.Equals(post_date.Day)
                        && Convert.ToDateTime(p.publishedDate).Year.Equals(post_date.Year) && Convert.ToDateTime(p.publishedDate).Month.Equals(post_date.Month)
                        select new PostWithCategories {
                            blogPostID = p.blogPostID,
                            post_title = p.post_title,
                            post_text = p.post_text,
                            slug = p.slug,
                            publishedDate = p.publishedDate,
                            createdDate = p.createdDate,
                            lastModified = p.lastModified,
                            meta_title = p.meta_title,
                            meta_description = p.meta_description,
                            active = p.active,
                            author = GetAuthor(p.userID),
                            categories = (from c in db.BlogCategories join pc in db.BlogPost_BlogCategories on c.blogCategoryID equals pc.blogCategoryID where pc.blogPostID.Equals(p.blogPostID) select c).ToList<BlogCategory>(),
                            comments = (from cm in db.Comments where cm.blogPostID.Equals(p.blogPostID) && cm.active.Equals(true) && cm.approved.Equals(true) select cm).ToList<Comment>()
                        }).First<PostWithCategories>();

                return post;
            } catch (Exception e) {
                return new PostWithCategories();
            }
        }
开发者ID:janiukjf,项目名称:curtmfg,代码行数:30,代码来源:Post.cs


示例6: FindVehicles

        public static List<FullVehicle> FindVehicles(string term = "")
        {
            List<FullVehicle> vehicles = new List<FullVehicle>();
            CurtDevDataContext db = new CurtDevDataContext();
            double query_year = 0;
            Double.TryParse(term, out query_year);
            vehicles = (from v in db.Vehicles
                        join y in db.Years on v.yearID equals y.yearID
                        join ma in db.Makes on v.makeID equals ma.makeID
                        join mo in db.Models on v.modelID equals mo.modelID
                        join s in db.Styles on v.styleID equals s.styleID
                        where s.style1.Contains(term) || mo.model1.Contains(term) || ma.make1.Contains(term) || y.year1.Equals(query_year)
                        orderby v.vehicleID
                        select new FullVehicle {
                            vehicleID = v.vehicleID,
                            yearID = v.yearID,
                            makeID = v.makeID,
                            modelID = v.modelID,
                            styleID = v.styleID,
                            aaiaID = s.aaiaID,
                            year = y.year1,
                            make = ma.make1,
                            model = mo.model1,
                            style = s.style1
                        }).ToList<FullVehicle>();

            return vehicles;
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:28,代码来源:VehicleModels.cs


示例7: Get

 public ContentPage Get(string name = "", int menuid = 0, bool authenticated = false)
 {
     ContentPage content = new ContentPage();
     try {
         CurtDevDataContext db = new CurtDevDataContext();
         content = (from s in db.SiteContents
                    where s.slug == name && s.published == true && s.active == true && s.websiteID.Equals(this.websiteID)
                    select new ContentPage {
                        contentID = s.contentID,
                        page_title = s.page_title,
                        content_type = s.content_type,
                        lastModified = s.lastModified,
                        createdDate = s.createdDate,
                        published = s.published,
                        meta_title = s.meta_title,
                        meta_description = s.meta_description,
                        keywords = s.keywords,
                        canonical = s.canonical,
                        active = s.active,
                        isPrimary = s.isPrimary,
                        slug = s.slug,
                        requireAuthentication = s.requireAuthentication,
                        revision = (db.SiteContentRevisions.Where(x => x.contentID == s.contentID).Where(x => x.active == true).First<SiteContentRevision>()),
                        menu = new MenuModel().GetByContentID(s.contentID, menuid, authenticated)
                    }).First<ContentPage>();
         return content;
     } catch (Exception e) { return content; }
 }
开发者ID:janiukjf,项目名称:curtmfg,代码行数:28,代码来源:SiteContentModel.cs


示例8: GetDealerLocation

 public static DealerLocation GetDealerLocation(int locationID = 0)
 {
     CurtDevDataContext db = new CurtDevDataContext();
     DealerLocation location = new DealerLocation();
     try {
         location = (from cl in db.CustomerLocations
                     join c in db.Customers on cl.cust_id equals c.cust_id
                     join dt in db.DealerTypes on c.dealer_type equals dt.dealer_type
                     join dtr in db.DealerTiers on c.tier equals dtr.ID
                     where cl.locationID.Equals(locationID)
                     select new DealerLocation {
                         State = cl.State,
                         customername = c.name,
                         dealerType = dt,
                         dealerTier = dtr,
                         locationID = cl.locationID,
                         name = cl.name,
                         address = cl.address,
                         city = cl.city,
                         stateID = cl.stateID,
                         postalCode = cl.postalCode,
                         email = cl.email,
                         phone = cl.phone,
                         fax = cl.fax,
                         latitude = cl.latitude,
                         longitude = cl.longitude,
                         cust_id = cl.cust_id,
                         isprimary = cl.isprimary,
                         contact_person = cl.contact_person,
                         websiteurl = (c.eLocalURL == null || c.eLocalURL.Trim() == "") ? ((c.website == null || c.website.Trim() == "") ? "" : c.website) : c.eLocalURL,
                         showWebsite = c.showWebsite
                     }).FirstOrDefault<DealerLocation>();
     } catch { };
     return location;
 }
开发者ID:janiukjf,项目名称:curtmfg,代码行数:35,代码来源:DealerModel.cs


示例9: Get

        public static CommentWithPost Get(int id = 0)
        {
            try
            {
                CurtDevDataContext db = new CurtDevDataContext();
                CommentWithPost comment = new CommentWithPost();

                comment = (from c in db.Comments
                           where c.commentID.Equals(id)
                           select new CommentWithPost
                           {
                               commentID = c.commentID,
                               blogPostID = c.blogPostID,
                               name = c.name,
                               email = c.email,
                               comment_text = c.comment_text,
                               createdDate = c.createdDate,
                               approved = c.approved,
                               active = c.active,
                               post = (from p in db.BlogPosts where p.blogPostID.Equals(c.blogPostID) select p).First<BlogPost>()
                           }).First<CommentWithPost>();

                return comment;
            }
            catch (Exception e)
            {
                return new CommentWithPost();
            }
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:29,代码来源:BlogComment.cs


示例10: Get

        public static FullFile Get(int id = 0)
        {
            FullFile file = new FullFile();
            try {
                CurtDevDataContext db = new CurtDevDataContext();
                file = (from f in db.Files
                        where f.fileID.Equals(id)
                        orderby f.createdDate descending
                        select new FullFile {
                            fileID = f.fileID,
                            name = f.name,
                            path = f.path,
                            height = f.height,
                            width = f.width,
                            size = f.size,
                            createdDate = f.createdDate,
                            created = String.Format("{0:ddd, dd MMM yyyy HH:mm:ss}", f.createdDate),
                            fileGalleryID = f.fileGalleryID,
                            fileExtID = f.fileExtID,
                            extension = (from fe in db.FileExts
                                         where fe.fileExtID.Equals(f.fileExtID)
                                         select new FileExtension {
                                             fileExtID = fe.fileExtID,
                                             fileExt1 = fe.fileExt1,
                                             fileExtIcon = fe.fileExtIcon,
                                             fileTypeID = fe.fileTypeID,
                                             FileType = db.FileTypes.Where(x => x.fileTypeID.Equals(fe.fileTypeID)).FirstOrDefault<FileType>()
                                         }).First<FileExtension>()
                        }).FirstOrDefault<FullFile>();

            } catch (Exception e) { }
            return file;
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:33,代码来源:File.cs


示例11: GetAll

        public static List<FullFile> GetAll()
        {
            List<FullFile> images = new List<FullFile>();
            try {
                CurtDevDataContext db = new CurtDevDataContext();

                images = (from f in db.Files
                          orderby f.name, f.createdDate descending
                          select new FullFile {
                              fileID = f.fileID,
                              name = f.name,
                              path = f.path,
                              height = f.height,
                              width = f.width,
                              size = f.size,
                              createdDate = f.createdDate,
                              fileGalleryID = f.fileGalleryID,
                              fileExtID = f.fileExtID,
                              extension = (from fe in db.FileExts
                                              where fe.fileExtID.Equals(f.fileExtID)
                                              select new FileExtension {
                                                  fileExtID = fe.fileExtID,
                                                  fileExt1 = fe.fileExt1,
                                                  fileExtIcon = fe.fileExtIcon,
                                                  fileTypeID = fe.fileTypeID,
                                                  FileType = db.FileTypes.Where(x => x.fileTypeID.Equals(fe.fileTypeID)).FirstOrDefault<FileType>()
                                              }).First<FileExtension>()
                          }).ToList<FullFile>();
            } catch (Exception e) { }

            return images;
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:32,代码来源:File.cs


示例12: Create

        public static FullVideo Create(Google.YouTube.Video ytVideo = null)
        {
            if (ytVideo == null) {
                throw new Exception("Invalid link");
            }
            CurtDevDataContext db = new CurtDevDataContext();
            Video new_video = new Video {
                embed_link = ytVideo.VideoId,
                title = ytVideo.Title,
                screenshot = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[2].Url : "/Content/img/noimage.jpg",
                description = ytVideo.Description,
                watchpage = ytVideo.WatchPage.ToString(),
                youtubeID = ytVideo.VideoId,
                dateAdded = DateTime.Now,
                sort = (db.Videos.Count() == 0) ? 1 : db.Videos.OrderByDescending(x => x.sort).Select(x => x.sort).First() + 1
            };
            db.Videos.InsertOnSubmit(new_video);
            db.SubmitChanges();

            FullVideo fullvideo = new FullVideo {
                videoID = new_video.videoID,
                embed_link = new_video.embed_link,
                dateAdded = new_video.dateAdded,
                sort = new_video.sort,
                videoTitle = new_video.title,
                thumb = (ytVideo.Thumbnails.Count > 0) ? ytVideo.Thumbnails[0].Url : "/Content/img/noimage.jpg"
            };

            return fullvideo;
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:30,代码来源:VideoModel.cs


示例13: GetMonths

        public static List<Archive> GetMonths()
        {
            try {
                CurtDevDataContext db = new CurtDevDataContext();
                List<Archive> archives = new List<Archive>();

                archives = (from p in db.BlogPosts
                            where p.publishedDate.Value != null && p.publishedDate.Value <= DateTime.Now && p.active.Equals(true)
                            orderby p.publishedDate.Value.Year descending, p.publishedDate.Value.Month descending
                            select new Archive
                            {
                                monthnum = Convert.ToInt16(Convert.ToDateTime(p.publishedDate).Month.ToString()),
                                month = Convert.ToDateTime(p.publishedDate).Month.ToString(),
                                year = Convert.ToDateTime(p.publishedDate).Year.ToString()
                            }).Distinct().ToList<Archive>();

                archives = (from a in archives
                            orderby a.year descending, a.monthnum
                            select a).Distinct().ToList<Archive>();

                return archives;
            } catch {
                return new List<Archive>();
            }
        }
开发者ID:janiukjf,项目名称:curtmfg,代码行数:25,代码来源:Archive.cs


示例14: Save

        public ActionResult Save(int id = 0, string question = "", string answer = "")
        {
            try {
                if (question.Length == 0) { throw new Exception("You must enter a question"); }
                if (answer.Length == 0) { throw new Exception("You must enter an answer"); }

                CurtDevDataContext db = new CurtDevDataContext();
                if (id == 0) {
                    FAQ faq = new FAQ {
                        answer = answer,
                        question = question
                    };
                    db.FAQs.InsertOnSubmit(faq);
                } else {
                    FAQ faq = db.FAQs.Where(x => x.faqID == id).FirstOrDefault<FAQ>();
                    faq.question = question;
                    faq.answer = answer;
                }
                db.SubmitChanges();

                return RedirectToAction("Index");
            } catch (Exception e) {
                if (id == 0) {
                    return RedirectToAction("Add", new { err = e.Message, q = question, a = answer });
                } else {
                    return RedirectToAction("Edit", new { id = id, err = e.Message, q = question, a = answer });
                }
            }
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:29,代码来源:FAQController.cs


示例15: DeleteCustomer

        public static string DeleteCustomer(int id)
        {
            try {
                CurtDevDataContext db = new CurtDevDataContext();

                // Delete any pricing entries for this customer
                List<CustomerPricing> prices = new List<CustomerPricing>();
                prices = (from cp in db.CustomerPricings
                          where cp.cust_id.Equals(id)
                          select cp).ToList<CustomerPricing>();
                db.CustomerPricings.DeleteAllOnSubmit<CustomerPricing>(prices);

                // Delete all locations for this customer
                List<CustomerLocation> locations = new List<CustomerLocation>();
                locations = (from cl in db.CustomerLocations
                             where cl.cust_id.Equals(id)
                             select cl).ToList<CustomerLocation>();
                db.CustomerLocations.DeleteAllOnSubmit<CustomerLocation>(locations);

                // Delete the customer record
                Customer cust = new Customer();
                cust = (from c in db.Customers
                        where c.cust_id.Equals(id)
                        select c).FirstOrDefault<Customer>();
                db.Customers.DeleteOnSubmit(cust);
                db.SubmitChanges();
                return "";
            } catch (Exception e) {
                return "Error while deleting.";
            }
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:31,代码来源:CustomerModel.cs


示例16: GetAll

        public static List<CommentWithPost> GetAll()
        {
            try
            {
                CurtDevDataContext db = new CurtDevDataContext();
                List<CommentWithPost> comments = new List<CommentWithPost>();

                comments = (from c in db.Comments
                        where c.active.Equals(true)
                        orderby c.approved, c.createdDate
                        select new CommentWithPost
                        {
                            commentID = c.commentID,
                            blogPostID = c.blogPostID,
                            name = c.name,
                            email = c.email,
                            comment_text = c.comment_text,
                            createdDate = c.createdDate,
                            approved = c.approved,
                            active = c.active,
                            post = (from p in db.BlogPosts where p.blogPostID.Equals(c.blogPostID) select p).First<BlogPost>()
                        }).ToList<CommentWithPost>();

                return comments;
            }
            catch (Exception e)
            {
                return new List<CommentWithPost>();
            }
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:30,代码来源:BlogComment.cs


示例17: GetAll

        /// <summary>
        /// Returns a List of all customers in the database, sorted by name ascending.
        /// </summary>
        /// <returns>List of Customer objects.</returns>
        public static List<FileType> GetAll()
        {
            CurtDevDataContext db = new CurtDevDataContext();
            List<FileType> types = db.FileTypes.OrderBy(x => x.fileType1).ToList<FileType>();

            return types;
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:11,代码来源:FileTypeModel.cs


示例18: Get

        public static PostWithCategories Get(int id = 0)
        {
            try {
                CurtDevDataContext db = new CurtDevDataContext();
                PostWithCategories post = new PostWithCategories();
                //post = db.Posts.Where(x => x.postID == id).Where(x => x.active == true).FirstOrDefault<Post>();
                post = (from p in db.BlogPosts
                         where p.blogPostID.Equals(id)
                         select new PostWithCategories {
                             blogPostID = p.blogPostID,
                             post_title = p.post_title,
                             slug = p.slug,
                             userID = p.userID,
                             post_text = p.post_text,
                             publishedDate = p.publishedDate,
                             createdDate = p.createdDate,
                             lastModified = p.lastModified,
                             keywords = p.keywords,
                             meta_title = p.meta_title,
                             meta_description = p.meta_description,
                             active = p.active,
                             author = GetAuthor(p.userID),
                             categories = (from c in db.BlogCategories join pc in db.BlogPost_BlogCategories on c.blogCategoryID equals pc.blogCategoryID where pc.blogPostID.Equals(p.blogPostID) select c).ToList<BlogCategory>(),
                             comments = (from cm in db.Comments where cm.blogPostID.Equals(p.blogPostID) && cm.approved.Equals(true) && cm.active.Equals(true) select cm).ToList<Comment>(),
                             mod_comments = (from cm in db.Comments where cm.blogPostID.Equals(p.blogPostID) && cm.approved.Equals(false) && cm.active.Equals(true) select cm).ToList<Comment>()
                         }).First<PostWithCategories>();

                return post;
            } catch (Exception e) {
                return new PostWithCategories();
            }
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:32,代码来源:BlogPost.cs


示例19: GetFullVehicle

        public static FullVehicle GetFullVehicle(int vehicleID = 0)
        {
            CurtDevDataContext db = new CurtDevDataContext();
            FullVehicle vehicle = new FullVehicle();

            if (vehicleID > 0) {
                vehicle = (from v in db.Vehicles
                           join y in db.Years on v.yearID equals y.yearID
                           join ma in db.Makes on v.makeID equals ma.makeID
                           join mo in db.Models on v.modelID equals mo.modelID
                           join s in db.Styles on v.styleID equals s.styleID
                           where v.vehicleID.Equals(vehicleID)
                           select new FullVehicle {
                               vehicleID = v.vehicleID,
                               yearID = v.yearID,
                               makeID = v.makeID,
                               modelID = v.modelID,
                               styleID = v.styleID,
                               aaiaID = s.aaiaID,
                               year = y.year1,
                               make = ma.make1,
                               model = mo.model1,
                               style = s.style1
                           }).FirstOrDefault<FullVehicle>();
            }
            return vehicle;
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:27,代码来源:VehicleModels.cs


示例20: GetAll

        public static List<PostWithCategories> GetAll()
        {
            try {
                CurtDevDataContext db = new CurtDevDataContext();
                List<PostWithCategories> posts = new List<PostWithCategories>();

                posts = (from p in db.BlogPosts
                        where p.active.Equals(true)
                        orderby p.publishedDate, p.createdDate
                        select new PostWithCategories {
                            blogPostID = p.blogPostID,
                            post_title = p.post_title,
                            slug = p.slug,
                            userID = p.userID,
                            post_text = p.post_text,
                            publishedDate = p.publishedDate,
                            createdDate = p.createdDate,
                            lastModified = p.lastModified,
                            meta_title = p.meta_title,
                            meta_description = p.meta_description,
                            active = p.active,
                            author = GetAuthor(p.userID),
                            categories = (from c in db.BlogCategories join pc in db.BlogPost_BlogCategories on c.blogCategoryID equals pc.blogCategoryID where pc.blogPostID.Equals(p.blogPostID) select c).ToList<BlogCategory>(),
                            comments = (from cm in db.Comments where cm.blogPostID.Equals(p.blogPostID) && cm.approved.Equals(true) && cm.active.Equals(true) select cm).ToList<Comment>(),
                            mod_comments = (from cm in db.Comments where cm.blogPostID.Equals(p.blogPostID) && cm.approved.Equals(false) && cm.active.Equals(true) select cm).ToList<Comment>()
                        }).ToList<PostWithCategories>();

                return posts;
            } catch (Exception e) {
                return new List<PostWithCategories>();
            }
        }
开发者ID:janiukjf,项目名称:CurtAdmin,代码行数:32,代码来源:BlogPost.cs



注:本文中的CurtDevDataContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Curve类代码示例发布时间:2022-05-24
下一篇:
C# CursorType类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap