当前位置: 首页>>代码示例>>C#>>正文


C# PetaPoco.Database类代码示例

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


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

示例1: btnOK_Click

        private void btnOK_Click(object sender, EventArgs ea)
        {
            var k = roleGridEdit1.GetSelectedValue();
            if (null == k) return;
            List<MenuCtlData> lst = new List<MenuCtlData>(100);
            foreach (TreeListNode td in treeCtl1.Nodes)
            {
                var mnugrp = td.GetValue(0).ToString();
                foreach (TreeListNode tds in td.Nodes)
                {
                    var mnuname = tds.GetValue(0).ToString();
                    foreach (TreeListNode tmd in tds.Nodes)
                    {
                        var mcd = tmd.Tag as MenuCtlData;
                        if (null != mcd)
                        {
                            mcd.IsEnabled = tmd.Checked;
                            mcd.MenuGrpName = mnugrp;
                            mcd.MenuName = mnuname;
                            lst.Add(mcd);
                        }
                        foreach (TreeListNode tkd in tmd.Nodes)
                        {
                            var md = tkd.Tag as MenuCtlData;
                            if (null == md) continue;
                            md.IsEnabled = tkd.Checked;
                            md.MenuGrpName = mnugrp; md.MenuName = mnuname;
                            lst.Add(md);
                        }
                    }
                }
            }
            var usr = GetCurUser<t_user>();
            using (var db = new Database())
            {

                var et = db.FirstOrDefault<t_roleset>("select * from t_roleset where [email protected]", k.Id);

                var roleset = et;
                if (et != null)
                {
                    roleset.RoleSetTree = Ultra.Web.Core.Common.ObjectHelper.SerializeJson(lst);
                }
                else
                {
                    roleset = new t_roleset
                    {
                        RoleSetTree = Ultra.Web.Core.Common.ObjectHelper.SerializeJson(lst),
                        RoleId = k.Id,
                        IsUsing = true,
                        RoleName = k.Name,
                        Guid = Guid.NewGuid(),
                        Creator =this.CurUser,
                        CreateDate = TimeSync.Default.CurrentSyncTime
                    };
                }
                db.Save(roleset);
            }
            MsgBox.ShowMessage(null, "保存成功!");
        }
开发者ID:MasterGao,项目名称:DevWinFormFrame,代码行数:60,代码来源:PermitView.cs

示例2: FrmNewRegist

        public FrmNewRegist()
        {
            InitializeComponent();
            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");

            //db.OpenSharedConnection();
            lstOutpatientCategory = db.Fetch<OUTPATIENT_CATEGORY>("");
            OUTPATIENT_CATEGORYTextEdit.Properties.TextEditStyle = DevExpress.XtraEditors.Controls.TextEditStyles.DisableTextEditor;
            OUTPATIENT_CATEGORYTextEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CATEGORY_ID"));
            OUTPATIENT_CATEGORYTextEdit.Properties.Columns.Add(new DevExpress.XtraEditors.Controls.LookUpColumnInfo("CATEGORY_NAME"));
            OUTPATIENT_CATEGORYTextEdit.Properties.DataSource = lstOutpatientCategory;

            OUTPATIENT_CATEGORYTextEdit.Properties.ValueMember = "CATEGORY_ID";         // 对应ID
            OUTPATIENT_CATEGORYTextEdit.Properties.DisplayMember = "CATEGORY_NAME";     // 显示内容

            patientReg.STATUS = 0;
            patientReg.OPERATOR = ClsFrmMng.WorkerID;

            pATIENTREGISTBindingSource.DataSource = patientReg;
            //db.CloseSharedConnection();

            ConditionValidationRule ruleNoEmpty = new ConditionValidationRule();
            ruleNoEmpty.ConditionOperator = ConditionOperator.IsNotBlank;
            ruleNoEmpty.ErrorText = "该项不能为空。";
            dxValidationProvider1.SetValidationRule(NAMETextEdit, ruleNoEmpty);
            dxValidationProvider1.SetValidationRule(OUTPATIENT_CATEGORYTextEdit, ruleNoEmpty);

            pATIENTBASEINFOBindingSource.DataSource = db.Fetch<PATIENT_BASEINFO>("");
            NAMETextEdit.Properties.EditValueChanged += Properties_EditValueChanged;
        }
开发者ID:hyblusea,项目名称:BloodInfo_MngPlatform,代码行数:31,代码来源:FrmNewRegist.cs

示例3: FrmDefaultDocAdvice_Cfg

        public FrmDefaultDocAdvice_Cfg()
        {
            InitializeComponent();

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");
        }
开发者ID:hyblusea,项目名称:BloodInfo_MngPlatform,代码行数:7,代码来源:FrmDefaultDocAdvice_Cfg.cs

示例4: GetAllComments

 private static List<Comment> GetAllComments()
 {
     using (var db = new Database("umbracoDbDSN"))
     {
         return db.Fetch<Comment>("SELECT * FROM forumComments WHERE isSpam = 1 ORDER BY id DESC");
     }
 }
开发者ID:joshbtn,项目名称:OurUmbraco,代码行数:7,代码来源:ForumSpamListComments.ascx.cs

示例5: Create

        //[RequireBasicAuthentication("AppHarbor")]
        public ActionResult Create(ProvisioningRequest provisionRequest)
        {
            if (provisionRequest == null || string.IsNullOrEmpty(provisionRequest.plan)) provisionRequest = new ProvisioningRequest() { callback_url = "/Response", heroku_id = Guid.NewGuid().ToString(), plan = "Free" };
            var db = new Database("DefaultConnection");
            Plan plan;
            if (!Enum.TryParse<Plan>(provisionRequest.plan, true, out plan))
            {
                throw new ArgumentException(string.Format("Plan \"{0}\" is not a valid plan", provisionRequest.plan));
            }

            var purchase = new Purchase()
            {
                CreatedBy = string.Format("{0};{1}", Request.GetForwardedHostAddress(), User.Identity.Name),
                UniqueId = Guid.NewGuid().ToString(),
                Plan = plan,
                ProviderId = provisionRequest.heroku_id,
                ProvisionStatus = ProvisionStatus.Provisioning,
                ApiKey = Guid.NewGuid().ToString(),
                ApiSecretKey = Guid.NewGuid().ToString()
            };
            // TODO: Provision the resource
            purchase.ProvisionStatus = ProvisionStatus.Provisioned;
            Purchase.Save(db, purchase);
            var output = new
            {
                id = purchase.UniqueId,
                config = new
                {
                    CONFIG_ApiKey = purchase.ApiKey,
                    CONFIG_ApiSecretKey = purchase.ApiSecretKey
                }
            };

            return Json(output, JsonRequestBehavior.AllowGet);
        }
开发者ID:s-leonard,项目名称:Addon,代码行数:36,代码来源:AddonController.cs

示例6: InitializeDatabase

 private void InitializeDatabase()
 {
     _db = new Database(_connectionStringName);
     _db.EnableAutoSelect = false;
     _db.EnableNamedParams = false;
     _db.ForceDateTimesToUtc = false;
 }
开发者ID:jmlsmn,项目名称:theShirtOff,代码行数:7,代码来源:ImageRepository.cs

示例7: FrmNewDav

        /// <summary>
        /// 
        /// </summary>
        /// <param name="base_id"></param>
        /// <param name="reg_id"></param>
        /// <param name="isTemp">0:长期, 1:临时</param>
        public FrmNewDav(Int64 base_id, Int64 reg_id, int isTemp)
        {
            InitializeComponent();
            if (isTemp == 0)
                this.Text = "新建长期医嘱";
            else
                this.Text = "新建临时医嘱";

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");

            _regID = reg_id;
            _baseID = base_id;
            _isTemp = isTemp;

            docAdv.REG_ID = _regID;
            docAdv.BASE_INFO_ID = _baseID;
            docAdv.OPERATOR = ClsFrmMng.WorkerID;
            docAdv.ADVICE_TYPE = _isTemp;
            docAdv.IS_DEL = 0;
            dOCADVICEBindingSource.DataSource = docAdv;

            vALUECODEBindingSource.DataSource = db.Fetch<VALUE_CODE>("");

            M_UNITLookUpEdit.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 14 });
            M_UNITLookUpEdit.Properties.DisplayMember = "DSP_MEMBER";
            M_UNITLookUpEdit.Properties.ValueMember = "VALUE_MEMBER";

            M_ACTIONLookUpEdit.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 13 });
            M_ACTIONLookUpEdit.Properties.DisplayMember = "DSP_MEMBER";
            M_ACTIONLookUpEdit.Properties.ValueMember = "VALUE_MEMBER";
        }
开发者ID:hyblusea,项目名称:BloodInfo_MngPlatform,代码行数:38,代码来源:FrmNewDav.cs

示例8: CreateTables

 public void CreateTables()
 {
     using (var db = new Database("DataSource=\"test.sdf\"; Password=\"chrissiespassword\"", "System.Data.SqlServerCe.4.0")) {
         db.Execute("CREATE TABLE Person (Id int IDENTITY(1,1) PRIMARY KEY, LastName nvarchar (40) NOT NULL, FirstName nvarchar (40), AddressId int NOT NULL);");
         db.Execute("CREATE TABLE Address (Id int IDENTITY(1,1) PRIMARY KEY, Street nvarchar (40) NOT NULL, HouseNumber nvarchar (10));");
     }
 }
开发者ID:tarwn,项目名称:PetaPocoSample,代码行数:7,代码来源:TwoTableSample.cs

示例9: getRides

        ////utility function to build the sql statement to perform the join
        //private static Sql sql()
        //{
        //    return Sql
        //        .Builder
        //        .Append("SELECT a.id, a.bike_id, a.rider_id, a.route_id, a.ride_date, a.notes,")
        //        .Append("a.reward, a.distance, a.paid, a.payment_id,")
        //        .Append("b.name AS route, c.name AS rider, d.name AS bike")
        //        .Append("FROM ride a, route b, rider c, bike d")
        //        .Append("WHERE a.route_id = b.id AND a.rider_id = c.id AND a.bike_id = d.id");
        //}

        public static List<Ride> getRides()
        {
            using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
            {
                return db.Fetch<Ride>("");
            }
        }
开发者ID:catflinger,项目名称:bikes,代码行数:19,代码来源:ride.cs

示例10: FrmRptPatientInfo

        public FrmRptPatientInfo()
        {
            InitializeComponent();

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");
        }
开发者ID:hyblusea,项目名称:BloodInfo_MngPlatform,代码行数:7,代码来源:FrmRptPatientInfo.cs

示例11: getRoute

 public static Route getRoute(int id)
 {
     using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
     {
         return db.FirstOrDefault<Route>("WHERE id = @0", id);
     }
 }
开发者ID:catflinger,项目名称:bikes,代码行数:7,代码来源:route.cs

示例12: Delete

        public void Delete(long id)
        {
            if (id <= 0)
            {
                return;
            }

            ApiAccessPolicy policy = new ApiAccessPolicy(typeof(MixERP.Net.Entities.Core.Account), "DELETE");
            policy.Authorize();

            if (!policy.IsAuthorized)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }

            try
            {
                using (Database db = new Database(Factory.GetConnectionString(), "Npgsql"))
                {
                    db.Delete("core.accounts", "account_id", null, id);
                }
            }
            catch
            {
                throw new HttpResponseException(HttpStatusCode.InternalServerError);
            }
        }
开发者ID:JonathanValle,项目名称:mixerp,代码行数:27,代码来源:Core.cs

示例13: getRoutes

     public static List<Route> getRoutes()
     {
         using (Database db = new PetaPoco.Database(ModelConfig.connectionStringName("bikes")))
         {
             return db.Fetch<Route>("WHERE deleted = FALSE");
         }
 }
开发者ID:catflinger,项目名称:bikes,代码行数:7,代码来源:route.cs

示例14: FrmNewCaseHis

        public FrmNewCaseHis(bool isAdd, Int64 base_id, Int64 reg_id)
        {
            InitializeComponent();

            //string sPwd = Des.Decrypt(ClsFrmMng.KEY, ConfigurationManager.AppSettings["DbPwd"]);
            db = new Database("XE");

            _reg_id = reg_id;
            _isAdd = isAdd;
            _baseID = base_id;

            //ConditionValidationRule ruleNoEmpty = new ConditionValidationRule();
            //ruleNoEmpty.ConditionOperator = ConditionOperator.IsNotBlank;
            //ruleNoEmpty.ErrorText = "该项不能为空。";
            //dxValidationProvider1.SetValidationRule(MEMOMemoEdit, ruleNoEmpty);
            //dxValidationProvider1.SetValidationRule(DOSE_MEMOMemoEdit, ruleNoEmpty);

            caseHis.REG_ID = _reg_id;
            caseHis.BASE_INFO_ID = _baseID;
            caseHis.OPERATOR = ClsFrmMng.WorkerID;
            cASEHISTORYBindingSource.DataSource = caseHis;

            lookUpEdit1.Properties.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 11 });
            lookUpEdit1.Properties.DisplayMember = "DSP_MEMBER";
            lookUpEdit1.Properties.ValueMember = "VALUE_MEMBER";

            vALUECODEBindingSource.DataSource = db.Fetch<VALUE_CODE>("where GROUPNAME = @0", new object[] { 181 });
        }
开发者ID:hyblusea,项目名称:BloodInfo_MngPlatform,代码行数:28,代码来源:FrmNewCaseHis.cs

示例15: SetPoints

        public void SetPoints(int trackId, TrackPoint[] points)
        {
            var sb = new StringBuilder();
            for (int i = 0; i < points.Length; i++)
            {
                if (i % 1000 == 0)
                {
                    if(sb.Length>0) sb.Remove(sb.Length - 1, 1);
                    sb.AppendLine(";").AppendLine("insert into MR.tTrackPoint (TrackId, Idx, Lat, Lon, Elevation, PointTime) values ");
                }

                var p = points[i];
                sb.AppendLine().Append("(")
                    .Append(trackId).Append(",")
                    .Append(i).Append(",")
                    .Append(p.Lat.ToString(CultureInfo.InvariantCulture)).Append(",")
                    .Append(p.Lon.ToString(CultureInfo.InvariantCulture)).Append(",")
                    .Append(p.Elevation.ToString(CultureInfo.InvariantCulture)).Append(",")
                    .Append("'").Append(p.PointTime.ToString("o",CultureInfo.InvariantCulture)).Append("'")
                    .Append("),");

            }
            var sql = sb.ToString().TrimEnd(',');
            var db = new Database(_config.ConnectionString, "System.Data.SqlClient");

            try
            {
                db.Execute(sql);
            }
            catch (SqlException ex)
            {
                throw new Exception(sql, ex);
            }
        }
开发者ID:maxime-paquatte,项目名称:MultiRando,代码行数:34,代码来源:TrackRepository.cs


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