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


C# BaseEntity.GetListDataTable方法代码示例

本文整理汇总了C#中BaseEntity.GetListDataTable方法的典型用法代码示例。如果您正苦于以下问题:C# BaseEntity.GetListDataTable方法的具体用法?C# BaseEntity.GetListDataTable怎么用?C# BaseEntity.GetListDataTable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BaseEntity的用法示例。


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

示例1: Main

        static void Main(string[] args)
        {
            // Oracle or SQl are same code : 
            // We have table in database  :Name is  Test and Columns (ID - Name - Price - Date) with the same sort and names
            // Table in sql or Oracle : (ID : int , Name : nvarchar(50) , Price : numeric(18,3) , Date : datetime)
            // in c# class : (ID : int , Name : string , Price : decimal , Date : DateTime)
            // Notice : Table Name = Class Name , Columns Names = Properties Names and Columns sorts = Properities sorts are Neccessary for working fine.

            BaseEntity<Test> dc = new BaseEntity<Test>("Data Source=MyOracleDB;Integrated Security=yes;", Databases.Oracle);    // Or Sql : Databases.Sql
            // 1 -  select * from Test
            List<Test> rows = dc.AllData().Data;
            // if error is happend you can know by :  dc.AllData().Returened.State = false;
            // Error message : dc.AllData().Returened.ErrorMessage       

            /*=========================================*/
            // 2 - SELECT * FROM Test WHERE Name LIKE '%test%'  
            List<Test> row = dc.Contains(new App.Entities.Models.Func()
            {
                ColumnName = "Name",
                TypeOutParam = App.Entities.Models.DataTypes._string,
                Value = "test"
            }).Data;
            /*=========================================*/
            // 3 - Delete from Test where ID = 1
            // Id you h've errors you can see it by :
            // Deletedrow.Returened.ErrorMessage
            // NO Errors :  Deletedrow.Returened.State == true
            var Deletedrow = dc.Delete(1);
            /*=========================================*/
            // 4 - Execute Stored Procedure : FindTest  this is for SQL
            // Sp has parameter : ID
            // Full Code Sp : 
            /*
                CREATE PROCEDURE [dbo].[FindTest] 
	            @ID int
                AS
                BEGIN
	                SELECT * From Test where ID = @ID		
                END
            */
            var Sp_Row = dc.Select(new App.Entities.Models.StoredProcedure()
            {
                arr = new System.Collections.ArrayList() { 1 },
                Params = new List<string>() { "ID" },
                StoredProcedureName = "FindTest"
            }).Data;
            /*=========================================*/
            // 5 - SELECT * From Test where ID = 1
            Test rowData = dc.Find(1).SingleData;
            /*=========================================*/
            // 6 - select top(1) from Test
            // dc.LastOrDefault() = select top(1) from test order by ID desc
            var FirstOrDefault = dc.FirstOrDefault();
            if (FirstOrDefault.SingleData != null)
            {
                Test record = FirstOrDefault.SingleData;
            }
            /*=========================================*/
            // 7 - select * from Test ==> but Datatable not List<Test>
            DataTable dt = dc.GetListDataTable().dataTable;
            /*=========================================*/
            // 8 - Insert into Test values('test2' , '2016-01-01 11:11:11' , 11);
            var rowInserted = dc.Insert(new Test() { Name = "test2", Date = DateTime.Now, Price = 11 });
            // For update
            var rowID = dc.Find(1).SingleData;
            var rowUpdated = dc.Update(rowID);
            /*=========================================*/
            // 9 - not supported in next version it 'll be supported
            // dc.Trigger(new App.Entities.Models.Trigger() {  })
            //  dc.Transaction(new App.Entities.Models.Trans() {   })
            /*=========================================*/
        }
开发者ID:mosaeedesraa,项目名称:SQL-Oracle-Dynamic-Entity-Framework,代码行数:72,代码来源:Program.cs


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