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


C# Database类代码示例

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


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

示例1: Page_Load

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            int id;
            if (!int.TryParse(Request.QueryString["id"], out id))
            {
                Response.Redirect("~/MediaCenter.aspx");
            }
            Database db = new Database();
            Lang lang = new Lang();
            db.AddParameter("@lang", lang.getCurrentLang());
            db.AddParameter("@id", id);
            DataTable dt = db.ExecuteDataTable("select top(3) * from Report where [email protected] and (not [email protected]) Order by id desc");
            Repeater1.DataSource = dt;
            Repeater1.DataBind();

            db.AddParameter("@lang", lang.getCurrentLang());
            dt = db.ExecuteDataTable("select top(3) * from SocialEvent where [email protected] Order by id desc");
            Repeater2.DataSource = dt;
            Repeater2.DataBind();

            db.AddParameter("@lang", lang.getCurrentLang());
            db.AddParameter("@id", id);
            dt = db.ExecuteDataTable("select * from Report where [email protected] and [email protected]");
            Repeater3.DataSource = dt;
            Repeater3.DataBind();

            if (dt.Rows.Count == 0)
            {
                Response.Redirect("~/MediaCenter.aspx");
            }
        }
    }
开发者ID:samercs,项目名称:NCSS,代码行数:34,代码来源:ReportDetails.aspx.cs

示例2: CreateDbAsync

		public async Task CreateDbAsync()
		{
			db = new Database(_connectionStringName);
			var all = Utils.LoadTextResource(string.Format("AsyncPoco.Tests.{0}_init.sql", _connectionStringName));
			foreach(var sql in all.Split(';').Select(s => s.Trim()).Where(s => s.Length > 0))
				await db.ExecuteAsync(sql);
		}
开发者ID:tmenier,项目名称:AsyncPoco,代码行数:7,代码来源:Tests.cs

示例3: runExtension

    public override void runExtension(Database db)
    {
        foreach (DBItem result in db.getSpawnableItems()) {
            // If this item can be made by other items, create a symmetric "Makes" property
            if (!result.propertyExists("madeby"))
                continue;

            foreach (KeyValuePair<string, string> ingredients in (List<KeyValuePair<string, string>>)result.getProperty("madeby")) {
                string ingredient1 = ingredients.Key;
                string ingredient2 = ingredients.Value;
                if (!db.itemExists(ingredient1) || !db.itemExists(ingredient2))
                    continue;
                DBItem dbIng1 = db.getItem(ingredient1);
                DBItem dbIng2 = db.getItem(ingredient2);
                if (!dbIng1.propertyExists("makes"))
                    dbIng1.setProperty("makes", new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>(ingredient2, result.ClassName) });
                else
                    (dbIng1.getProperty("makes") as List<KeyValuePair<string, string>>).Add(new KeyValuePair<string, string>(ingredient2, result.ClassName));
                if (!dbIng2.propertyExists("makes"))
                    dbIng2.setProperty("makes", new List<KeyValuePair<string, string>>() { new KeyValuePair<string, string>(ingredient1, result.ClassName) });
                else
                    (dbIng2.getProperty("makes") as List<KeyValuePair<string, string>>).Add(new KeyValuePair<string, string>(ingredient1, result.ClassName));

            }
        }
    }
开发者ID:alect,项目名称:Puzzledice,代码行数:26,代码来源:MakesExtension.cs

示例4: HandleParameter

        public static string HandleParameter( string name, object value, Database db, ref List<Parameter> ps )
        {
            string ret = db.DelimColumn( name );
            if( value != null && value.GetType() == typeof(SpecialValue) )
            {
                // Special Handling
                var sv = (SpecialValue)value;

                switch( sv.Name )
                {
                case "is-null":
                    ret += " IS NULL";
                    return ret;
                case "is-not-null":
                    ret += " IS NOT NULL";
                    return ret;
                case "lit-value":
                    var lv = (LiteralValue)sv;
                    ret += " = " + lv.TextValue;
                    return ret;
                default:
                    throw new ArgumentOutOfRangeException( "value", "Unhandled Special Value passed in." );
                }
            }

            var pname = "auto_"+name+"_"+ps.Count.ToString();
            ret += " = " + db.DelimParameter( pname );

            ps.Add( new Parameter( pname, value ) );

            return ret;
        }
开发者ID:REMSLogic,项目名称:REMSLogic,代码行数:32,代码来源:Command.cs

示例5: SetUp

    public void SetUp()
    { 
      var home = _context.CurrentDatabase.GetItem("/sitecore/content/home");

      var contentRootItem = TestUtil.CreateContentFromFile("TestResources\\items in workflow.xml", _testRoot);
      _publishableItem = contentRootItem.Axes.GetChild("publishable");
      _itemInWorkflow = contentRootItem.Axes.GetChild("in draft");
      _noWorkflow = contentRootItem.Axes.GetChild("no workflow");

      _noWorkflow.Editing.BeginEdit();
      _noWorkflow[FieldIDs.Workflow] = string.Empty;
      _noWorkflow[FieldIDs.WorkflowState] = string.Empty;
      _noWorkflow.Editing.EndEdit();

      // publish the root item only so publishing on any item works
      var dbs = new Database[]{ Sitecore.Configuration.Factory.GetDatabase("web")};
      var langs = new Language[]{ Sitecore.Context.Language};
      var handle = PublishManager.PublishItem(_testRoot, dbs, langs, false, true);

      PublishManager.PublishItem(contentRootItem, dbs, langs, false, true);

      var jobs = from j in Sitecore.Jobs.JobManager.GetJobs()
                 where j.Name.Contains("Publish") && j.Name.Contains("web")
                 select j;

      foreach (var job in jobs)
        job.Wait();
    }
开发者ID:KerwinMa,项目名称:revolver,代码行数:28,代码来源:PublishItem.cs

示例6: GenerateAnalyticObject

    public static GameObject GenerateAnalyticObject(Database database, int analyticType)
    {
        //Make sure to generate the correct type of harness (disk harness)
        GameObject currentHarness = Generate((int)View_Type.DiskHarness);
        Transform harnessTransform = currentHarness.transform;

        List<DatabaseUtilities.Table> tableInfo = database.tables;
        int tableCount = tableInfo.Count;

        GameObject[] anaObjects = new GameObject[tableCount];

        if(analyticType == 1)
        {
            DatabaseUtilities.Table infoObject = tableInfo[0];
            List<DatabaseUtilities.Column> dataTypes = infoObject.columns;
            int dataTypeSize = dataTypes.Count;

            GameObject[] disks = new GameObject[dataTypeSize];

            for(int i = 0; i < dataTypeSize; i++)
            {
                disks[i] = GenerateDiskObj(dataTypes[i], harnessTransform);
            }

            currentHarness.GetComponent<DiskHarness>().Initialize(disks, dataTypes);
        }

        return currentHarness;
    }
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:29,代码来源:ViewAssembler.cs

示例7: ClearPanelsAkrFromDrawing

        public void ClearPanelsAkrFromDrawing(Database db)
        {
            SelectionBlocks sel = new SelectionBlocks(db);
             sel.SelectAKRPanelsBtr();

             List<ObjectId> idsBtrPanelsAkr = sel.IdsBtrPanelAr.ToList();
             idsBtrPanelsAkr.AddRange(sel.IdsBtrPanelSb);

             List<ObjectId> idsBtrOther = new List<ObjectId>();

             foreach (ObjectId idBtrPanel in idsBtrPanelsAkr)
             {
            using (var btrPanel = idBtrPanel.Open(OpenMode.ForRead) as BlockTableRecord)
            {
               foreach (ObjectId idBlRefPanel in btrPanel.GetBlockReferenceIds(false, true))
               {
                  using (var blRefPanel = idBlRefPanel.Open(OpenMode.ForWrite, false, true) as BlockReference)
                  {
                     blRefPanel.Erase();
                  }
               }
               foreach (ObjectId idEnt in btrPanel)
               {
                  using (var blRef = idEnt.Open(OpenMode.ForRead, false, true) as BlockReference)
                  {
                     if (blRef == null) continue;
                     idsBtrOther.Add(blRef.BlockTableRecord);
                  }
               }
            }
             }

             eraseIdsDbo(idsBtrPanelsAkr);
             eraseIdsDbo(idsBtrOther);
        }
开发者ID:vildar82,项目名称:PanelColorAlbum,代码行数:35,代码来源:BaseService.cs

示例8: Start

	private IEnumerator Start () {
		Debug.LogFormat ("Data path = {0}", Application.persistentDataPath);

#if UNITY_EDITOR_WIN
		Log.SetLogger(new UnityLogger());
#endif
		_db = Manager.SharedInstance.GetDatabase ("spaceshooter");
		_pull = _db.CreatePullReplication (GameController.SYNC_URL);
		_pull.Continuous = true;
		_pull.Start ();
		while (_pull != null && _pull.Status == ReplicationStatus.Active) {
			yield return new WaitForSeconds(0.5f);
		}

		var doc = _db.GetExistingDocument ("player_data");
		if (doc != null) {
			//We have a record!  Get the ship data, if possible.
			string assetName = String.Empty;
			if(doc.UserProperties.ContainsKey("ship_data")) {
				assetName = doc.UserProperties ["ship_data"] as String;
			}
			StartCoroutine(LoadAsset (assetName));
		} else {
			//Create a new record
			doc = _db.GetDocument("player_data");
			doc.PutProperties(new Dictionary<string, object> { { "ship_data", String.Empty } });
		}

		doc.Change += DocumentChanged;
		_push = _db.CreatePushReplication (new Uri ("http://127.0.0.1:4984/spaceshooter"));
		_push.Start();
	}
开发者ID:serjee,项目名称:space-shooter,代码行数:32,代码来源:AssetChangeListener.cs

示例9: FailIfSeedDoesNotMatch

 public void FailIfSeedDoesNotMatch()
 {
     var dataspec = new DatabaseSpec();
     dataspec.AddSchema<Employees>();
     var database = new Database(ConnectionString);
     Assert.That(database.Satisfies(dataspec), Is.False);
 }
开发者ID:benjaminjohndyer,项目名称:SQLRoller,代码行数:7,代码来源:OnIdendityInt.cs

示例10: FailIfIncrementDoesNotMatch

 public void FailIfIncrementDoesNotMatch()
 {
     var dataspec = new DatabaseSpec();
     dataspec.AddSchema<Shippers>();
     var database = new Database(ConnectionString);
     Assert.That(database.Satisfies(dataspec), Is.False);
 }
开发者ID:benjaminjohndyer,项目名称:SQLRoller,代码行数:7,代码来源:OnIdendityInt.cs

示例11: UpdateStatus

        public static void UpdateStatus(int id, string tableName, string fileName,string title,  int archiveId, IQueryTable toTable, QueryColumn toStatus, QueryColumn toPrimary)
        {
            NBearLite.DbProviders.DbProvider provider =
                        NBearLite.DbProviders.DbProviderFactory.CreateDbProvider(
                                null,
                                "System.Data.SqlServerCe",
                                @"Data Source=enforce.sdf;
                                  Encrypt Database=True;
                                  Password=enforce_123456;
                                  File Mode=shared read;
                                  Persist Security Info=False;");
            Database database = new Database(provider);

            UpdateSqlSection section = new UpdateSqlSection(database, toTable);
            section.AddColumn(toStatus, 2); // 2 代表已归档
            section.Where(toPrimary == id);
            section.Execute();

            InsertSqlSection insert = new InsertSqlSection(database, DataBases.ArchiveExt);
            insert.AddColumn(DataBases.ArchiveExt.ArchiveID, archiveId);
            insert.AddColumn(DataBases.ArchiveExt.TableName, tableName);
            insert.AddColumn(DataBases.ArchiveExt.PrimaryValue, id);
            insert.AddColumn(DataBases.ArchiveExt.FileName, fileName);
            insert.AddColumn(DataBases.ArchiveExt.Title, title);
            insert.AddColumn(DataBases.ArchiveExt.CreateTime, DateTime.Now);
            insert.AddColumn(DataBases.ArchiveExt.ExchangeGUID, CommonInvoke.NewGuid);
            insert.Execute();
        }
开发者ID:Oman,项目名称:Maleos,代码行数:28,代码来源:Utility.cs

示例12: GetAll

        public IEnumerable<object> GetAll(string typeName, string sortColumn, string sortOrder)
        {
            var currentType = Type.GetType(typeName);
            var tableName = (TableNameAttribute)Attribute.GetCustomAttribute(currentType, typeof(TableNameAttribute));
            var uioMaticAttri = (UIOMaticAttribute)Attribute.GetCustomAttribute(currentType, typeof(UIOMaticAttribute));
            var strTableName = tableName.Value;

            var db = (Database)DatabaseContext.Database;
            if(!string.IsNullOrEmpty(uioMaticAttri.ConnectionStringName))
                db = new Database(uioMaticAttri.ConnectionStringName);

            if (strTableName.IndexOf("[") < 0)
            {
                strTableName = "[" + strTableName + "]";
            }

            var query = new Sql().Select("*").From(strTableName);


            if (!string.IsNullOrEmpty(sortColumn) && !string.IsNullOrEmpty(sortOrder))
            {
                var strSortColumn = sortColumn;
                if (strSortColumn.IndexOf("[") < 0)
                {
                    strSortColumn = "[" + strSortColumn + "]";
                }

                query.OrderBy(strSortColumn + " " + sortOrder);
            }

            foreach (dynamic item in db.Fetch<dynamic>(query))
            {
                // get settable public properties of the type
                var props = currentType.GetProperties(BindingFlags.Public | BindingFlags.Instance)
                    .Where(x => x.GetSetMethod() != null);

                // create an instance of the type
                var obj = Activator.CreateInstance(currentType);
                

                // set property values using reflection
                var values = (IDictionary<string, object>)item;
                foreach (var prop in props)
                {
                    var columnAttri =
                           prop.GetCustomAttributes().Where(x => x.GetType() == typeof(ColumnAttribute));

                    var propName = prop.Name;
                    if (columnAttri.Any())
                        propName = ((ColumnAttribute)columnAttri.FirstOrDefault()).Name;
                    if(values.ContainsKey(propName))
                        prop.SetValue(obj, values[propName]);
                }

                yield return obj;
            }
            

            
        }
开发者ID:paulsoerensen,项目名称:UIOMatic,代码行数:60,代码来源:PetaPocoObjectController.cs

示例13: SaleProcessor

 public SaleProcessor(Database database, IOutgoingCommandEnvelopeRouter envelopeRouter, SaleRepository saleRepository, InventoryRepository inventoryRepository)
 {
     this.database = database;
     this.envelopeRouter = envelopeRouter;
     this.saleRepository = saleRepository;
     this.inventoryRepository = inventoryRepository;
 }
开发者ID:asanyaga,项目名称:BuildTest,代码行数:7,代码来源:SaleProcessor.cs

示例14: CodeAction

        public void CodeAction(BonoboGitServerContext context)
        {
            _db = context.Database;

            if (UpgradeHasAlreadyBeenRun())
            {
                return;
            }

            using (var trans = context.Database.BeginTransaction())
            {
                try
                {
                    RenameTables();
                    CreateTables();
                    CopyData();
                    AddRelations();
                    DropRenamedTables();
                    trans.Commit();
                }
                catch (Exception)
                {
                    trans.Rollback();
                    throw;
                }
            }
        }
开发者ID:Guzhongren,项目名称:Bonobo-Git-Server,代码行数:27,代码来源:AddGuidColumn.cs

示例15: CreateSnaphot

        public void CreateSnaphot(string SnapshotName, string SourceDatabase, string SnapshotLocation)
        {
            Database SrcDatabase = _Server.Databases[SourceDatabase];

            Database SnapshotDatabase = new Database(_Server, SnapshotName);
            SnapshotDatabase.DatabaseSnapshotBaseName = SourceDatabase;

            foreach (FileGroup Group in SrcDatabase.FileGroups)
            {
                SnapshotDatabase.FileGroups.Add(new FileGroup(SnapshotDatabase, Group.Name));
                foreach (DataFile File in Group.Files)
                {
                    SnapshotDatabase.FileGroups[Group.Name].Files.Add(
                        new DataFile(
                            SnapshotDatabase.FileGroups[Group.Name],
                            File.Name,
                            SnapshotLocation + @"\" + SnapshotName + "_" + File.Name + ".ss")
                    );
                }
            }

            DropSnapshot(SnapshotName);

            SnapshotDatabase.Create();

            _Repository.Connection.ChangeDatabase(SourceDatabase);
        }
开发者ID:gravesmw,项目名称:SQLSnapshot,代码行数:27,代码来源:SnapshotManagement.cs


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