码迷,mamicode.com
首页 > 数据库 > 详细

C#里System.Data.SQLite中对GUID的处理

时间:2016-05-31 10:37:36      阅读:794      评论:0      收藏:0      [点我收藏+]

标签:

 string sqlstring = "select * from endpoint_policy where HEX([UserGuid]) =‘" + CommonHelper.ConvertGuid(uguid) + "";
 var query = db.Database.SqlQuery<endpoint_policy>(sqlstring).AsQueryable();
 var endpoint_policy = new PagedList<endpoint_policy>(query.OrderByDescending(c => c.CreatedOnUtc), pageIndex, pageSize);
public static string ConvertGuid(Guid gd)
{
            string sgd = gd.ToString().ToUpper();
            string sVar = "";
            int i;
            foreach (string sv in new string[] { sgd.Substring(0, 8), sgd.Substring(9, 4), sgd.Substring(14, 4) })
            {
                for (i = sv.Length - 2; i >= 0; i -= 2)
                {
                    sVar += sv.Substring(i, 2);
                }
            }
            sgd = sgd.Substring(19).Replace("-", "");
            for (i = 0; i < 8; i++)
            {
                sVar += sgd.Substring(2 * i, 2);
            }
            return sVar;
 }

 

C#里System.Data.SQLite中对GUID的处理

标签:

原文地址:http://www.cnblogs.com/mschen/p/5544945.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!