我的c#代码生成器(生成SQL2005的和ACCESS的)
生成 内容 1.ACCESS 2.net2.0的泛型操作的 3.。net3.5-4.0的linq to entity 生成 的net2.0 代码 MODEL using System;using System.Collections.Generic;namespace ChineseCode.Bll{public class News{/// summary/// /// /summarypublic int NewsId{set;get;
生成内容
1.ACCESS
2.net2.0的泛型操作的
3.。net3.5-4.0的linq to entity
生成的net2.0代码
MODEL
using System; using System.Collections.Generic; namespace ChineseCode.Bll { public class News { /// <summary> /// /// </summary> public int NewsId { set; get; } /// <summary> /// /// </summary> public int UserID { set; get; } /// <summary> /// /// </summary> public int TypeID { set; get; } /// <summary> /// /// </summary> public string Author { set; get; } /// <summary> /// /// </summary> public string Title { set; get; } /// <summary> /// /// </summary> public string Excerpts { set; get; } /// <summary> /// /// </summary> public string Body { set; get; } /// <summary> /// /// </summary> public string Image { set; get; } /// <summary> /// /// </summary> public int Views { set; get; } /// <summary> /// /// </summary> public bool IsApprived { set; get; } /// <summary> /// /// </summary> public bool CheckResult { set; get; } /// <summary> /// /// </summary> public int DisplayOrder { set; get; } /// <summary> /// /// </summary> public bool IsCommend { set; get; } /// <summary> /// /// </summary> public string Sourse { set; get; } /// <summary> /// /// </summary> public DateTime CreateDate { set; get; } /// <summary> /// /// </summary> public string PostIP { set; get; } /// <summary> /// /// </summary> public DateTime? UpdateDate { set; get; } /// <summary> ///获取单个模型 /// </summary> private Users _Users; public Users Users { get { if (_Users == null) { _Users = UsersManager.GetModel(this.UserID); return _Users; } return _Users; } } /// <summary> ///获取单个模型 /// </summary> private NewsType _NewsType; public NewsType NewsType { get { if (_NewsType == null) { _NewsType = NewsTypeManager.GetModel(this.TypeID); return _NewsType; } return _NewsType; } } } }
BLL
<pre class="html" name="code">using System; using System.Collections.Generic; using System.Text; using JrdLibrary; using System.Data; using System.Data.SqlClient; namespace ChineseCode.Bll { public class NewsManager { #region 获取实体方法 /// <summary> /// 获取一个实体类 /// </summary> public static News GetModel(SqlDataReader reader) { return SqlDataReaderExt.ReaderToModel<News>(reader); } /// <summary> /// 获取一个实体类集合 /// </summary> public static List<News> GetList(SqlDataReader reader) { return SqlDataReaderExt.ReaderToList<News>(reader); } #endregion /// <summary> /// 创建一个有默认值的Model /// </summary> public static News CreateModel() { News model = new News(); model.Views = 0; model.IsApprived = true; model.CheckResult = true; model.DisplayOrder = 0; model.IsCommend = false; model.CreateDate = DateTime.Now; return model; } /// <summary> /// 增加一条数据 /// </summary> public static int Insert(News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into Jrd_News("); strSql.Append("UserID,TypeID,Author,Title,Excerpts,Body,Image,Views,IsApprived,CheckResult,DisplayOrder,IsCommend,Sourse,CreateDate,PostIP)"); strSql.Append(" values ("); strSql.Append("@UserID,@TypeID,@Author,@Title,@Excerpts,@Body,@Image,@Views,@IsApprived,@CheckResult,@DisplayOrder,@IsCommend,@Sourse,@CreateDate,@PostIP)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int,4), new SqlParameter("@TypeID", SqlDbType.Int,4), new SqlParameter("@Author",SqlDbType.NVarChar,100), new SqlParameter("@Title",SqlDbType.NVarChar,400), new SqlParameter("@Excerpts",SqlDbType.NVarChar,1000), new SqlParameter("@Body",SqlDbType.NText), new SqlParameter("@Image",SqlDbType.VarChar,100), new SqlParameter("@Views", SqlDbType.Int,4), new SqlParameter("@IsApprived",SqlDbType.Bit,1), new SqlParameter("@CheckResult",SqlDbType.Bit,1), new SqlParameter("@DisplayOrder", SqlDbType.Int,4), new SqlParameter("@IsCommend",SqlDbType.Bit,1), new SqlParameter("@Sourse",SqlDbType.NVarChar,200), new SqlParameter("@CreateDate",SqlDbType.DateTime), new SqlParameter("@PostIP",SqlDbType.VarChar,20) }; parameters[0].Value = model.UserID; parameters[1].Value = model.TypeID; parameters[2].Value = model.Author; parameters[3].Value = model.Title; parameters[4].Value = model.Excerpts; parameters[5].Value = model.Body; parameters[6].Value = model.Image; parameters[7].Value = model.Views; parameters[8].Value = model.IsApprived; parameters[9].Value = model.CheckResult; parameters[10].Value = model.DisplayOrder; parameters[11].Value = model.IsCommend; parameters[12].Value = model.Sourse; parameters[13].Value = model.CreateDate; parameters[14].Value = model.PostIP; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } } /// <summary> /// 更新一条数据 /// </summary> public static bool Update(News model) { StringBuilder strSql = new StringBuilder(); strSql.Append("update Jrd_News set "); strSql.Append("UserID=@userID,TypeID=@typeID,Author=@author,Title=@title,Excerpts=@excerpts,Body=@body,Image=@image,Views=@views,IsApprived=@isApprived,CheckResult=@checkResult,DisplayOrder=@displayOrder,IsCommend=@isCommend,Sourse=@sourse,PostIP=@postIP,UpdateDate=@updateDate "); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@UserID", SqlDbType.Int,4), new SqlParameter("@TypeID", SqlDbType.Int,4), new SqlParameter("@Author",SqlDbType.NVarChar,100), new SqlParameter("@Title",SqlDbType.NVarChar,400), new SqlParameter("@Excerpts",SqlDbType.NVarChar,1000), new SqlParameter("@Body",SqlDbType.NText), new SqlParameter("@Image",SqlDbType.VarChar,100), new SqlParameter("@Views", SqlDbType.Int,4), new SqlParameter("@IsApprived",SqlDbType.Bit,1), new SqlParameter("@CheckResult",SqlDbType.Bit,1), new SqlParameter("@DisplayOrder", SqlDbType.Int,4), new SqlParameter("@IsCommend",SqlDbType.Bit,1), new SqlParameter("@Sourse",SqlDbType.NVarChar,200), new SqlParameter("@PostIP",SqlDbType.VarChar,20), new SqlParameter("@UpdateDate",SqlDbType.DateTime), new SqlParameter("@NewsId", SqlDbType.Int,4) }; parameters[0].Value = model.UserID; parameters[1].Value = model.TypeID; parameters[2].Value = model.Author; parameters[3].Value = model.Title; parameters[4].Value = model.Excerpts; parameters[5].Value = model.Body; parameters[6].Value = model.Image; parameters[7].Value = model.Views; parameters[8].Value = model.IsApprived; parameters[9].Value = model.CheckResult; parameters[10].Value = model.DisplayOrder; parameters[11].Value = model.IsCommend; parameters[12].Value = model.Sourse; parameters[13].Value = model.PostIP; parameters[14].Value = model.UpdateDate; parameters[15].Value = model.NewsId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// <summary> /// 删除一条数据 /// </summary> public static bool Delete(int newsId) { StringBuilder strSql=new StringBuilder(); strSql.Append("delete from Jrd_News "); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int,4) }; parameters[0].Value = newsId; int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters); if (rows > 0) { return true; } else { return false; } } /// <summary> /// 是否存在该记录 /// </summary> public static bool Exists(int newsId) { StringBuilder strSql=new StringBuilder(); strSql.Append("select count(1) from Jrd_News"); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int,4) }; parameters[0].Value = newsId; return DbHelperSQL.Exists(strSql.ToString(),parameters); } /// <summary> /// 得到一个对象实体 /// </summary> public static News GetModel(int newsId) { StringBuilder strSql=new StringBuilder(); strSql.Append("select top 1 NewsId,UserID,TypeID,Author,Title,Excerpts,Body,Image,Views,IsApprived,CheckResult,DisplayOrder,IsCommend,Sourse,CreateDate,PostIP from Jrd_News "); strSql.Append(" where NewsId=@NewsId"); SqlParameter[] parameters = { new SqlParameter("@NewsId", SqlDbType.Int,4) }; parameters[0].Value = newsId; return GetModel(DbHelperSQL.ExecuteReader(strSql.ToString(),parameters)); } /// <summary> /// 获得全部数据 /// </summary> public static List<News> GetAll() { StringBuilder strSql=new StringBuilder(); strSql.Append("select NewsId,UserID,TypeID,Author,Title,Excerpts,Body,Image,Views,IsApprived,CheckResult,DisplayOrder,IsCommend,Sourse,CreateDate,PostIP "); strSql.Append(" FROM Jrd_News "); return GetList(DbHelperSQL.ExecuteReader(strSql.ToString(),null)); } /// <summary> ///根据UserID获取列表 /// </summary> public static List<News> GetNewsByUserID(string andStr,int userID, int PageSize,int PageCurrent,string FdOrder, ref int totalCount) { SqlQuery query = new SqlQuery(); query.Add("UserID", userID, QueryOperator.Equal); return GetPager(query.GetWhere + andStr, PageSize, PageCurrent, FdOrder, SortType.DESC, ref totalCount); } /// <summary> ///根据TypeID获取列表 /// </summary> public static List<News> GetNewsByTypeID(string andStr,int typeID, int PageSize,int PageCurrent,string FdOrder, ref int totalCount) { SqlQuery query = new SqlQuery(); query.Add("TypeID", typeID, QueryOperator.Equal); return GetPager(query.GetWhere + andStr, PageSize, PageCurrent, FdOrder, SortType.DESC, ref totalCount); } /// <summary> /// 根据排序分页获取数据列表 /// </summary> public static List<News> GetPagerByDisplayOrder(string strWhere, int PageSize, int PageCurrent,SortType sort, ref int RecordCount) { return GetPager(strWhere, PageSize, PageCurrent, "DisplayOrder" , sort, ref RecordCount); } /// <summary> /// 根据浏览分页获取数据列表 /// </summary> public static List<News> GetPagerByViews(string strWhere, int PageSize, int PageCurrent, SortType sort, ref int RecordCount) { return GetPager(strWhere, PageSize, PageCurrent, "Views" , sort, ref RecordCount); } /// <summary> /// 分页获取数据列表 /// </summary> public static List<News> GetPager(string strWhere, int PageSize, int PageCurrent, string FdOrder,SortType sort, ref int RecordCount) { string sqlStr="select cast(NewsId as int) as NewsId,UserID,TypeID,Author,Title,Excerpts,Body,Image,Views,IsApprived,CheckResult,DisplayOrder,IsCommend,Sourse,CreateDate,PostIP,UpdateDate from Jrd_News "; if (string.IsNullOrEmpty(FdOrder) || FdOrder == "") FdOrder ="NewsId Desc"; else FdOrder = FdOrder + " " + sort.ToString(); return GetList(PagerBll.GetPagerReader(sqlStr + strWhere, PageSize, PageCurrent, "", FdOrder, ref RecordCount)); } } }

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



1. Open settings in Windows 11. You can use Win+I shortcut or any other method. 2. Go to the Apps section and click Apps & Features. 3. Find the application you want to prevent from running in the background. Click the three-dot button and select Advanced Options. 4. Find the [Background Application Permissions] section and select the desired value. By default, Windows 11 sets power optimization mode. It allows Windows to manage how applications work in the background. For example, once you enable battery saver mode to preserve battery, the system will automatically close all apps. 5. Select [Never] to prevent the application from running in the background. Please note that if you notice that the program is not sending you notifications, failing to update data, etc., you can

DeepSeek cannot convert files directly to PDF. Depending on the file type, you can use different methods: Common documents (Word, Excel, PowerPoint): Use Microsoft Office, LibreOffice and other software to export as PDF. Image: Save as PDF using image viewer or image processing software. Web pages: Use the browser's "Print into PDF" function or the dedicated web page to PDF tool. Uncommon formats: Find the right converter and convert it to PDF. It is crucial to choose the right tools and develop a plan based on the actual situation.

Oracle can read dbf files through the following steps: create an external table and reference the dbf file; query the external table to retrieve data; import the data into the Oracle table.

Since the launch of ChatGLM-6B on March 14, 2023, the GLM series models have received widespread attention and recognition. Especially after ChatGLM3-6B was open sourced, developers are full of expectations for the fourth-generation model launched by Zhipu AI. This expectation has finally been fully satisfied with the release of GLM-4-9B. The birth of GLM-4-9B In order to give small models (10B and below) more powerful capabilities, the GLM technical team launched this new fourth-generation GLM series open source model: GLM-4-9B after nearly half a year of exploration. This model greatly compresses the model size while ensuring accuracy, and has faster inference speed and higher efficiency. The GLM technical team’s exploration has not

Yesterday, BotanixLabs announced that it has completed a total of US$11.5 million in financing, with participation from Polychain Capital, Placeholder Capital and others. Financing will be used to build the decentralized EVM equivalent of BTCL2Botanix. Spiderchain combines the ease of use of EVM with the security of Bitcoin. Since the testnet went live in November 2023, there have been more than 200,000 active addresses. Odaily will analyze Botanix’s characteristic mechanism and testnet interaction process in this article. Botanix According to the official definition, Botanix is a decentralized Turing-complete L2EVM built on Bitcoin and consists of two core components: Ethereum Virtual Machine

Produced by 51CTO technology stack (WeChat ID: blog51cto) Mistral released its first code model Codestral-22B! What’s crazy about this model is not only that it’s trained on over 80 programming languages, including Swift, etc. that many code models ignore. Their speeds are not exactly the same. It is required to write a "publish/subscribe" system using Go language. The GPT-4o here is being output, and Codestral is handing in the paper so fast that it’s hard to see! Since the model has just been launched, it has not yet been publicly tested. But according to the person in charge of Mistral, Codestral is currently the best-performing open source code model. Friends who are interested in the picture can move to: - Hug the face: https

Access Violation error is a run-time error that occurs when a program accesses a memory location beyond its memory allocation, causing the program to crash or terminate abnormally. Solutions include: checking array boundaries; using pointers correctly; using appropriate memory allocation functions; freeing freed memory; checking for memory overflows; updating drivers and systems; checking third-party libraries; using a debugger to trace execution; contacting the software vendor for support.

Beihang's research team used a diffusion model to "replicate" the Earth? At any location around the world, the model can generate remote sensing images of multiple resolutions, creating rich and diverse "parallel scenes." Moreover, complex geographical features such as terrain, climate, and vegetation have all been taken into consideration. Inspired by Google Earth, Beihang's research team "loaded" satellite remote sensing images of the entire Earth into a deep neural network from an overhead perspective. Based on such a network, the team built MetaEarth, a global top-down visual generation model. MetaEarth has 600 million parameters and can generate remote sensing images with multiple resolutions, unbounded and covering any geographical location around the world. Compared with previous research, the global remote sensing image generation model has
