OracleSugar ORM框架的誕生,代碼開源

来源:http://www.cnblogs.com/sunkaixuan/archive/2016/09/14/5871358.html
-Advertisement-
Play Games

經過四天的努力終於將SqlSugar ORM 成功支持ORACLE資料庫 優點: 1、高性能,達到原生最高水準,比SqlHelper性能要高,比Dapper快30% 比EF快50% 2、支持多種資料庫 ,sql版本更新最快,其它會定期更新,可以在多種資料庫用一種編程方式 3、支持.net Core ...


 經過四天的努力終於將SqlSugar ORM 成功支持ORACLE資料庫 

 

優點:

1、高性能,達到原生最高水準,比SqlHelper性能要高,比Dapper快30% 比EF快50% 

2、支持多種資料庫 ,sql版本更新最快,其它會定期更新,可以在多種資料庫用一種編程方式

3、支持.net Core

4、支持多庫並行計算

5、帶有實體生成函數和T4模版生成實體

6、無需任何配置 ,還你一個乾凈的model

 

 

 

 

2、功能介紹/Product function introduction

 

查詢/Search

 

1、Queryable用於拉姆達操作資料庫

 

2、SqlQuery用於執行SQL和存儲過程

 

3、Sqlable一種更新近SQL的寫法

 

1、Queryable 用於拉姆達表達式操作(支持Join多表)    / Select single table or view

   //查詢所有
                var student = db.Queryable<STUDENT>().ToList();
                var studentDynamic = db.Queryable<STUDENT>().ToDynamic();
                var studentJson = db.Queryable<STUDENT>().ToJson();

                //查詢單條
                var single = db.Queryable<STUDENT>().Single(c => c.ID == 1);
                //查詢單條沒有記錄返回空對象
                var singleOrDefault = db.Queryable<STUDENT>().SingleOrDefault(c => c.ID == 11111111);
                //查詢單條沒有記錄返回空對象
                var single2 = db.Queryable<STUDENT>().Where(c => c.ID == 1).SingleOrDefault();

                //查詢第一條
                var first = db.Queryable<STUDENT>().Where(c => c.ID == 1).First();
                var first2 = db.Queryable<STUDENT>().Where(c => c.ID == 1).FirstOrDefault();

                //取10-20條
                var page1 = db.Queryable<STUDENT>().Where(c => c.ID > 10).OrderBy(it => it.ID).Skip(10).Take(20).ToList();

                //上一句的簡化寫法,同樣取10-20條
                var page2 = db.Queryable<STUDENT>().Where(c => c.ID > 10).OrderBy(it => it.ID).ToPageList(2, 10);

                //查詢條數
                var count = db.Queryable<STUDENT>().Where(c => c.ID > 10).Count();

                //從第2條開始以後取所有
                var skip = db.Queryable<STUDENT>().Where(c => c.ID > 10).OrderBy(it => it.ID).Skip(2).ToList();

                //取前2條
                var take = db.Queryable<STUDENT>().Where(c => c.ID > 10).OrderBy(it => it.ID).Take(2).ToList();

                // Not like 
                string conval = "a";
                var notLike = db.Queryable<STUDENT>().Where(c => !c.NAME.Contains(conval.ToString())).ToList();
                //Like
                conval = "";
                var like = db.Queryable<STUDENT>().Where(c => c.NAME.Contains(conval)).ToList();

                //支持字元串Where 讓你解決,更複雜的查詢
                var student12 = db.Queryable<STUDENT>().Where(c => "a" == "a").Where("id>:id", new { id = 1 }).ToList();
                var student13 = db.Queryable<STUDENT>().Where(c => "a" == "a").Where("id>100 ").ToList();


                //存在記錄反回true,則否返回false
                bool isAny100 = db.Queryable<STUDENT>().Any(c => c.ID == 100);
                bool isAny1 = db.Queryable<STUDENT>().Any(c => c.ID == 1);


                //獲取最大Id
                object maxId = db.Queryable<STUDENT>().Max(it => it.ID);
                int maxId1 = db.Queryable<STUDENT>().Max(it => it.ID).ObjToInt();//拉姆達
                int maxId2 = db.Queryable<STUDENT>().Max<STUDENT, int>("id"); //字元串寫法

                //獲取最小
                int minId1 = db.Queryable<STUDENT>().Where(c => c.ID > 0).Min(it => it.ID).ObjToInt();//拉姆達
                int minId2 = db.Queryable<STUDENT>().Where(c => c.ID > 0).Min<STUDENT, int>("id");//字元串寫法


                //order By 
                var orderList = db.Queryable<STUDENT>().OrderBy("id desc,name asc").ToList();//字元串支持多個排序
                //可以多個order by表達示
                var order2List = db.Queryable<STUDENT>().OrderBy(it => it.NAME).OrderBy(it => it.ID, OrderByType.desc).ToList(); // order by name as ,order by id desc

                //In
                var intArray = new[] { "5", "2", "3" };
                var intList = intArray.ToList();
                var list0 = db.Queryable<STUDENT>().In(it => it.ID, 1, 2, 3).ToList();
                var list1 = db.Queryable<STUDENT>().In(it => it.ID, intArray).ToList();
                var list2 = db.Queryable<STUDENT>().In("id", intArray).ToList();
                var list3 = db.Queryable<STUDENT>().In(it => it.ID, intList).ToList();
                var list4 = db.Queryable<STUDENT>().In("id", intList).ToList();

                //分組查詢
                var list7 = db.Queryable<STUDENT>().Where(c => c.ID < 20).GroupBy(it => it.SEX).Select("sex,count(*) count").ToDynamic();
                var list8 = db.Queryable<STUDENT>().Where(c => c.ID < 20).GroupBy(it => it.SEX).GroupBy(it => it.ID).Select("id,sex,count(*) count").ToDynamic();
                List<SexTotal> list9 = db.Queryable<STUDENT>().Where(c => c.ID < 20).GroupBy(it => it.SEX).Select<STUDENT, SexTotal>("SEX,count(*) COUNT").ToList();
                List<SexTotal> list10 = db.Queryable<STUDENT>().Where(c => c.ID < 20).GroupBy("sex").Select<STUDENT, SexTotal>("SEX,count(*) COUNT").ToList();
                //SELECT Sex,Count=count(*)  FROM Student  WHERE 1=1  AND  (id < 20)    GROUP BY Sex --生成結果



                //2表關聯查詢
                var jList = db.Queryable<STUDENT>()
                .JoinTable<STUDENT, SCHOOL>((s1, s2) => s1.SCH_ID == s2.ID) //預設left join
                .Where<STUDENT, SCHOOL>((s1, s2) => s1.ID == 1)
                .Select("s1.*,s2.name as schName")
                .ToDynamic();

                /*等於同於
                 SELECT s1.*,s2.name as schName 
                 FROM [Student]  s1 
                 LEFT JOIN [School]  s2 ON  s1.sch_id  = s2.id 
                 WHERE  s1.id  = 1 */

                //2表關聯查詢並分頁
                var jList2 = db.Queryable<STUDENT>()
                .JoinTable<STUDENT, SCHOOL>((s1, s2) => s1.SCH_ID == s2.ID) //預設left join
                    //如果要用inner join這麼寫
                    //.JoinTable<Student, School>((s1, s2) => s1.sch_id == s2.id  ,JoinType.INNER)
                .Where<STUDENT, SCHOOL>((s1, s2) => s1.ID > 1)
                .OrderBy<STUDENT, SCHOOL>((s1, s2) => s1.NAME)
                .Skip(10)
                .Take(20)
                .Select("s1.*,s2.name as schName")
                .ToDynamic();

                //3表查詢並分頁
                var jList3 = db.Queryable<STUDENT>()
               .JoinTable<STUDENT, SCHOOL>((s1, s2) => s1.SCH_ID == s2.ID) // left join  School s2  on s1.id=s2.id
               .JoinTable<STUDENT, SCHOOL>((s1, s3) => s1.SCH_ID == s3.ID) // left join  School s3  on s1.id=s3.id
               .Where<STUDENT, SCHOOL>((s1, s2) => s1.ID > 1)  // where s1.id>1
               .Where<STUDENT>(s1 => s1.ID > 0)
               .OrderBy<STUDENT, SCHOOL>((s1, s2) => s1.ID) //order by s1.id 多個order可以  .oderBy().orderby 疊加 
               .Skip(10)
               .Take(20)
               .Select("s1.*,s2.name as schName,s3.name as schName2")//select目前只支持這種寫法
               .ToDynamic();


                //上面的方式都是與第一張表join,第三張表想與第二張表join寫法如下
                List<classNew> jList4 = db.Queryable<STUDENT>()
                 .JoinTable<STUDENT, SCHOOL>((s1, s2) => s1.SCH_ID == s2.ID) // left join  School s2  on s1.id=s2.id
                 .JoinTable<STUDENT, SCHOOL, AREA>((s1, s2, a1) => a1.ID == s2.AREAID)// left join  Area a1  on a1.id=s2.AreaId
                 .Select<STUDENT, SCHOOL, AREA, classNew>((s1, s2, a1) => new classNew { NEWID = s1.ID, STUDENTNAME = s1.NAME, SCHOOLNAME = s2.NAME, AREANAME = a1.NAME }).ToList();




                //最多支持5表查詢,太過複雜的建議用Sqlable或者SqlQuery,我們的Queryable只適合輕量級的查詢





                //拼接
                var queryable = db.Queryable<STUDENT>().Where(it => true);
                if (maxId.ObjToInt() == 1)
                {
                    queryable.Where(it => it.ID == 1);
                }
                else
                {
                    queryable.Where(it => it.ID == 2);
                }
                var listJoin = queryable.ToList();


                //queryable和SqlSugarClient解耦
                var par = new Queryable<STUDENT>().Where(it => it.ID == 1);//聲名沒有connection對象的Queryable
                par.DB = db;
                var listPar = par.ToList();


                //查看生成的sql和參數
                var id=1;
                var sqlAndPars = db.Queryable<STUDENT>().Where(it => it.ID == id).OrderBy(it => it.ID).ToSql();



                //函數的支持(欄位暫不支持函數,只有參數支持) 目前只支持這麼多
                var par1 = "2015-1-1"; var par2 = "   我 有空格, ";
                var r1 = db.Queryable<STUDENT>().Where(it => it.NAME == par1.ObjToString()).ToSql(); //ObjToString會將null轉轉成""
                var r2 = db.Queryable<INSERTTEST>().Where(it => it.D1 == par1.ObjToDate()).ToSql();
                var r3 = db.Queryable<INSERTTEST>().Where(it => it.ID == 1.ObjToInt()).ToSql();//ObjToInt會將null轉轉成0
                var r4 = db.Queryable<INSERTTEST>().Where(it => it.ID == 2.ObjToDecimal()).ToSql();
                var r5 = db.Queryable<INSERTTEST>().Where(it => it.ID == 3.ObjToMoney()).ToSql();
                var r6 = db.Queryable<INSERTTEST>().Where(it => it.V1 == par2.Trim()).ToSql();
                var convert1 = db.Queryable<STUDENT>().Where(c => c.NAME == "a".ToString()).ToList();
                var convert2 = db.Queryable<STUDENT>().Where(c => c.ID == Convert.ToInt32("1")).ToList();// 
                var convert3 = db.Queryable<STUDENT>().Where(c => DateTime.Now > Convert.ToDateTime("2015-1-1")).ToList();
                var convert4 = db.Queryable<STUDENT>().Where(c => DateTime.Now > DateTime.Now).ToList();
                var c1 = db.Queryable<STUDENT>().Where(c =>c.NAME.Contains("a")).ToList();
                var c2 = db.Queryable<STUDENT>().Where(c => c.NAME.StartsWith("a")).ToList();
                var c3 = db.Queryable<STUDENT>().Where(c => c.NAME.EndsWith("a")).ToList();

 

 

 

2、SqlQuery 用於執行原生SQL和存儲過程   /   Execution of native SQL

using (var db = SugarDao.GetInstance())
            {
                //轉成list
                List<STUDENT> list1 = db.SqlQuery<STUDENT>("select * from Student");
                //轉成list帶參
                List<STUDENT> list2 = db.SqlQuery<STUDENT>("select * from Student where id=:id", new { id = 1 });
                //轉成dynamic
                dynamic list3 = db.SqlQueryDynamic("select * from student");
                //轉成json
                string list4 = db.SqlQueryJson("select * from student");
                //返回int
                var list5 = db.SqlQuery<int>("select   id from Student where rownum=1").SingleOrDefault();
                //反回鍵值
                Dictionary<string, string> list6 = db.SqlQuery<KeyValuePair<string, string>>("select id,name from Student").ToDictionary(it => it.Key, it => it.Value);
                //反回List<string[]>
                var list7 = db.SqlQuery<string[]>("select   id,name from Student where rownum=1").SingleOrDefault();

                //存儲過程
                //var spResult = db.SqlQuery<SCHOOL>(@"begin exec sp_school (:p1,:p2); end;", new { p1 = 1, p2 = 2 });

                //獲取第一行第一列的值
                string v1 = db.GetString("select '張三' as name from dual");
                int v2 = db.GetInt("select 1 as name  from dual");
                double v3 = db.GetDouble("select 1 as name  from dual");
                decimal v4 = db.GetDecimal("select 1 as name  from dual");
                //....
            }

 

 

3、Sqlable 更貼近SQL的一種編程方式,適用於複雜查詢 / Complex query

 //多表查詢
                List<SCHOOL> dataList = db.Sqlable()
                   .From("school", "s")
                   .Join("student", "st", "st.id", "s.id", JoinType.INNER)
                   .Join("student", "st2", "st2.id", "st.id", JoinType.LEFT)
                   .Where("s.id>100 and s.id<:id")
                   .Where("1=1")//可以多個WHERE
                   .OrderBy("s.id")
                   .SelectToList<SCHOOL/*新的Model我這裡沒有所以寫的School*/>("st.*", new { id = 1 });

                //多表分頁
                List<SCHOOL> dataPageList = db.Sqlable()
                    .From("school", "s")
                    .Join("student", "st", "st.id", "s.id", JoinType.INNER)
                    .Join("student", "st2", "st2.id", "st.id", JoinType.LEFT)
                    .Where("s.id>100 and s.id<100")
                    .SelectToPageList<SCHOOL>("st.*", "s.id", 1, 10);

                //多表分頁WHERE加子查詢
                List<SCHOOL> dataPageList2 = db.Sqlable()
                    .From("school", "s")
                    .Join("student", "st", "st.id", "s.id", JoinType.INNER)
                    .Join("student", "st2", "st2.id", "st.id", JoinType.LEFT)
                    .Where("s.id>100 and s.id<100 and s.id in (select 1 as id from dual )" /*這裡面寫子查詢都可以*/)
                    .SelectToPageList<SCHOOL>("st.*", "s.id", 1, 10);



                //--------轉成List Dynmaic 或者 Json-----//

                //不分頁
                var list1 = db.Sqlable().From("student", "s").Join("school", "l", "s.sch_id", "l.id and l.id=:id", JoinType.INNER).SelectToDynamic("*", new { id = 1 });
                var list2 = db.Sqlable().From("student", "s").Join("school", "l", "s.sch_id", "l.id and l.id=:id", JoinType.INNER).SelectToJson("*", new { id = 1 });
                var list3 = db.Sqlable().From("student", "s").Join("school", "l", "s.sch_id", "l.id and l.id=:id", JoinType.INNER).SelectToDataTable("*", new { id = 1 });

                //分頁
                var list4 = db.Sqlable().From("student", "s").Join("school", "l", "s.sch_id", "l.id and l.id=:id", JoinType.INNER).SelectToPageDynamic("s.*", "l.id", 1, 10, new { id = 1 });
                var list5 = db.Sqlable().From("student", "s").Join("school", "l", "s.sch_id", "l.id and l.id=:id", JoinType.INNER).SelectToPageTable("s.*", "l.id", 1, 10, new { id = 1 });
                var list6 = db.Sqlable().From("student", "s").Join("school", "l", "s.sch_id", "l.id and l.id=:id", JoinType.INNER).SelectToPageDynamic("s.*", "l.id", 1, 10, new { id = 1 });


                //--------拼接-----//
                Sqlable sable = db.Sqlable().From<STUDENT>("s").Join<SCHOOL>("l", "s.sch_id", "l.id", JoinType.INNER);
                string name = "a";
                int id = 1;
                if (!string.IsNullOrEmpty(name))
                {
                    sable = sable.Where("s.name=:name");
                }
                if (!string.IsNullOrEmpty(name))
                {
                    sable = sable.Where("s.id=:id or s.id=100");
                }
                if (id > 0)
                {
                    sable = sable.Where("l.id in (select  id from school where rownum<10)");//where加子查詢
                }
                var pars = new { id = id, name = name };
                int pageCount = sable.Count(pars);
                var list7 = sable.SelectToPageList<STUDENT>("s.*", "l.id desc", 1, 20, pars);
View Code

 

 

4、新容器轉換 / To new container

 using (SqlSugarClient db = SugarDao.GetInstance())
            {
                var list2 = db.Queryable<STUDENT>().Where(c => c.ID < 10).Select(c => new classNew { NEWID = c.ID, NEWNAME = c.NAME, XX_NAME = c.NAME }).ToList();//不支持匿名類轉換,也不建議使用

                var list3 = db.Queryable<STUDENT>().Where(c => c.ID < 10).Select(c => new { newid = c.ID, newname = c.NAME, xx_name = c.NAME }).ToDynamic();//匿名類轉換

                var list4 = db.Queryable<STUDENT>().Where(c => c.ID < 10).Select("id as newid, name as newname ,name as xx_name").ToDynamic();//匿名類轉換

                var jList1 = db.Queryable<STUDENT>()
                 .JoinTable<STUDENT, SCHOOL>((s1, s2) => s1.SCH_ID == s2.ID) // left join  School s2  on s1.id=s2.id
                 .Where<STUDENT, SCHOOL>((s1, s2) => s1.ID > 1)  // where s1.id>1
                 .OrderBy<STUDENT, SCHOOL>((s1, s2) => s1.ID) //order by s1.id 多個order可以  .oderBy().orderby 疊加 
                 .Skip(1)
                 .Take(2)
                 .Select<STUDENT, SCHOOL, classNew>((s1, s2) => new classNew() { NEWID = s1.ID, NEWNAME = s2.NAME, XX_NAME = s1.NAME })//select目前只支持這種寫法
                 .ToList();

                var jList2 = db.Queryable<STUDENT>()
                .JoinTable<STUDENT, SCHOOL>((s1, s2) => s1.SCH_ID == s2.ID) // left join  School s2  on s1.id=s2.id
                .Where<STUDENT, SCHOOL>((s1, s2) => s1.ID > 1)  // where s1.id>1
                .OrderBy<STUDENT, SCHOOL>((s1, s2) => s1.ID) //order by s1.id 多個order可以  .oderBy().orderby 疊加 
                .Skip(1)
                .Take(2)
                .Select<STUDENT, SCHOOL, classNew>((s1, s2) => new classNew() { NEWID = s1.ID, NEWNAME = s1.NAME, XX_NAME = s1.NAME })//select目前只支持這種寫法
                .ToDynamic();


                var jList3 = db.Queryable<STUDENT>()
                .JoinTable<STUDENT, SCHOOL>((s1, s2) => s1.SCH_ID == s2.ID) // left join  School s2  on s1.id=s2.id
                .Where<STUDENT, SCHOOL>((s1, s2) => s1.ID > 1)  // where s1.id>1
                .OrderBy<STUDENT, SCHOOL>((s1, s2) => s1.ID) //order by s1.id 多個order可以  .oderBy().orderby 疊加 
                .Skip(1)
                .Take(2)
                .Select<STUDENT, classNew>(s1 => new classNew() { NEWID = s1.ID, NEWNAME = s1.NAME, XX_NAME = s1.NAME })//select目前只支持這種寫法
                .ToDynamic();
            }

 

 

 

添加/Add

            //設置序列,程式起動時設置一次便可
            OracleConfig.SequenceMapping = new List<PubModel.SequenceModel>()
            {
                  new PubModel.SequenceModel(){ ColumnName="ID", TableName="STUDENT", Value="SEQ_D"} 
            };
            using (SqlSugarClient db = SugarDao.GetInstance())//開啟資料庫連接
            {


                STUDENT s = new STUDENT()
                {
                    NAME = "" + new Random().Next(1, int.MaxValue)
                };

                db.Insert(s); //插入一條記錄 (有主鍵也好,沒主鍵也好,有自增列也好都可以插進去)


                List<STUDENT> list = new List<STUDENT>()
                {
                     new STUDENT()
                {
                     NAME=""+new Random().Next(1,int.MaxValue)
                },
                 new STUDENT()
                {
                     NAME=""+new Random().Next(1,int.MaxValue)
                }
                };

                db.InsertRange(list); //批量插入
            }

 

 

更新/Update

            int id = 11;
using (var db = SugarDao.GetInstance())
            {
                //指定列更新
                db.Update<SCHOOL>(new { name = "藍翔14" }, it => it.ID == 14);
                db.Update<SCHOOL, int>(new { name = "藍翔11 23 12", areaId=2 }, 11, 23, 12);
                db.Update<SCHOOL, string>(new { name = "藍翔2" }, new string[] { "11", "21" });
                db.Update<SCHOOL>(new { name = "藍翔2" }, it => it.ID == id);

   

                //支持欄位指定列更新,適合動態許可權
                var dic =new Dictionary<string, string>();
                dic.Add("name","第十三條");
                dic.Add("areaId", "1");
                db.Update<SCHOOL,int>(dic, 13);
                db.Update<SCHOOL>(dic, it => it.ID == 13);



                //整個實體更新
                db.Update(new SCHOOL { ID = 16, NAME = "藍翔16", AREAID=1 });
                db.Update<SCHOOL>(new SCHOOL { ID = id, NAME = "藍翔18", AREAID=2 }, it => it.ID == 18);
                db.Update<SCHOOL>(new SCHOOL() { ID = 11, NAME = "xx" });

                //設置不更新列
                db.DisableUpdateColumns = new string[] { "CreateTime" };//設置CreateTime不更新

                TESTUPDATECOLUMNS updObj = new TESTUPDATECOLUMNS()
                {
                    VGUID = "542b5a27-6984-47c7-a8ee-359e483c8470",
                    NAME = "xx",
                    NAME2 = "xx2",
                    IDENTITYFIELD = 1,
                    CREATETIME = null
                };

                //CreateTime將不會被更新
                db.Update(updObj);
                //以前實現這種更新需要用指定列的方式實現,現在就簡單多了。
               
            }

 

 

刪除和假刪除/Delete And False Delete

您的分享是我們最大的動力!

-Advertisement-
Play Games
更多相關文章
  • 命名空間:Windows.Data.Json在Windows Runtime中,可以使用Json類對獲取的Json字元串進行操作,相比DataContractJsonSerializer類操作更加直觀。例如獲取一個繞口令API返回的Json中的對象: //返回的Json字元串: { "code":2 ...
  • 關於Net Core 多平臺程式的Framework問題: (本文只是推測,歡迎大家指正) 最近在研究NetCore的多平臺問題,起因是有一個Winform的項目,由於跨平臺的要求,想改為NetCore的MVC6項目,但是同時也想保留原來的Winform項目。 所以,一些DLL必須要做到即可以在Wi ...
  • 隱藏手機號、郵箱等敏感信息 Intro 做項目的時候,頁面上有一些敏感信息,需要用“*”隱藏一些比較重要的信息,於是打算寫一個通用的方法。 Let's do it ! Method 1:指定左右字元數量 Method 1.1 中間的*的個數和實際長度有關 Method 1.2 : 中間的*的個數固定 ...
  • 關於本配置節的內容不算多,但關於ASP.NET編譯的內容還是有一點的,鄙人認為只是瞭解一下即可,主要影響到部署。 在 App_Code 文件夾中使用多種編程語言 因為 App_Code 文件夾中的源代碼要編譯成單個程式集,所以 App_Code 文件夾中的所有文件必須使用相同的編程語言編寫。例如,A ...
  • 通過html導出excel ...
  • js代碼: ...
  • 使用SendMessage向另一進程發送WM_COPYDATA消息 Send端: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows; u ...
  • R軟體功能非常強大,可以很好的進行各類統計,並能輸出圖形。下麵介紹一種R語言和C#進行通信的方法,並將R繪圖結果顯示到WinForm UI界面上。 1 前提準備 安裝R軟體,需要安裝32位的R軟體,64位的調用會報錯。另外就是講R添加到電腦環境變數中。 打開R軟體,安裝包 scatterplot3d ...
一周排行
    -Advertisement-
    Play Games
  • 移動開發(一):使用.NET MAUI開發第一個安卓APP 對於工作多年的C#程式員來說,近來想嘗試開發一款安卓APP,考慮了很久最終選擇使用.NET MAUI這個微軟官方的框架來嘗試體驗開發安卓APP,畢竟是使用Visual Studio開發工具,使用起來也比較的順手,結合微軟官方的教程進行了安卓 ...
  • 前言 QuestPDF 是一個開源 .NET 庫,用於生成 PDF 文檔。使用了C# Fluent API方式可簡化開發、減少錯誤並提高工作效率。利用它可以輕鬆生成 PDF 報告、發票、導出文件等。 項目介紹 QuestPDF 是一個革命性的開源 .NET 庫,它徹底改變了我們生成 PDF 文檔的方 ...
  • 項目地址 項目後端地址: https://github.com/ZyPLJ/ZYTteeHole 項目前端頁面地址: ZyPLJ/TreeHoleVue (github.com) https://github.com/ZyPLJ/TreeHoleVue 目前項目測試訪問地址: http://tree ...
  • 話不多說,直接開乾 一.下載 1.官方鏈接下載: https://www.microsoft.com/zh-cn/sql-server/sql-server-downloads 2.在下載目錄中找到下麵這個小的安裝包 SQL2022-SSEI-Dev.exe,運行開始下載SQL server; 二. ...
  • 前言 隨著物聯網(IoT)技術的迅猛發展,MQTT(消息隊列遙測傳輸)協議憑藉其輕量級和高效性,已成為眾多物聯網應用的首選通信標準。 MQTTnet 作為一個高性能的 .NET 開源庫,為 .NET 平臺上的 MQTT 客戶端與伺服器開發提供了強大的支持。 本文將全面介紹 MQTTnet 的核心功能 ...
  • Serilog支持多種接收器用於日誌存儲,增強器用於添加屬性,LogContext管理動態屬性,支持多種輸出格式包括純文本、JSON及ExpressionTemplate。還提供了自定義格式化選項,適用於不同需求。 ...
  • 目錄簡介獲取 HTML 文檔解析 HTML 文檔測試參考文章 簡介 動態內容網站使用 JavaScript 腳本動態檢索和渲染數據,爬取信息時需要模擬瀏覽器行為,否則獲取到的源碼基本是空的。 本文使用的爬取步驟如下: 使用 Selenium 獲取渲染後的 HTML 文檔 使用 HtmlAgility ...
  • 1.前言 什麼是熱更新 游戲或者軟體更新時,無需重新下載客戶端進行安裝,而是在應用程式啟動的情況下,在內部進行資源或者代碼更新 Unity目前常用熱更新解決方案 HybridCLR,Xlua,ILRuntime等 Unity目前常用資源管理解決方案 AssetBundles,Addressable, ...
  • 本文章主要是在C# ASP.NET Core Web API框架實現向手機發送驗證碼簡訊功能。這裡我選擇是一個互億無線簡訊驗證碼平臺,其實像阿裡雲,騰訊雲上面也可以。 首先我們先去 互億無線 https://www.ihuyi.com/api/sms.html 去註冊一個賬號 註冊完成賬號後,它會送 ...
  • 通過以下方式可以高效,並保證數據同步的可靠性 1.API設計 使用RESTful設計,確保API端點明確,並使用適當的HTTP方法(如POST用於創建,PUT用於更新)。 設計清晰的請求和響應模型,以確保客戶端能夠理解預期格式。 2.數據驗證 在伺服器端進行嚴格的數據驗證,確保接收到的數據符合預期格 ...