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


C# IDbConnection.SqlList方法代码示例

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


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

示例1: UpdateContent

        internal static void UpdateContent(IDbConnection Db, GXAmiDevice device, DeviceContentType content)
        {
            string query;
            if (content == DeviceContentType.All)
            {
                device.ProfileGuid = Db.Select<GXAmiDeviceProfile>(q => q.Id == device.ProfileId)[0].Guid;
                SortedList<ulong, object> items = new SortedList<ulong, object>();
                //Get categories.
                device.Categories = Db.Select<GXAmiCategory>(q => q.DeviceID == device.Id).ToArray();
                foreach(GXAmiCategory cat in device.Categories)
                {
                    items.Add(cat.Id, cat);
                }
                //Get tables.
                device.Tables = Db.Select<GXAmiDataTable>(q => q.DeviceID == device.Id).ToArray();
                foreach(GXAmiDataTable table in device.Tables)
                {
                    items.Add(table.Id, table);
                }
                //Get properties.
                query = string.Format("SELECT * FROM {0} WHERE DeviceID = {1} ORDER BY ParentID, ID",
                                                    GuruxAMI.Server.AppHost.GetTableName<GXAmiProperty>(Db),
                                                    device.Id);
                List<GXAmiProperty> properties = Db.SqlList<GXAmiProperty>(query);
                ulong id = 0;
                List<GXAmiProperty> list = new List<GXAmiProperty>();
                foreach (GXAmiProperty it in properties)
                {
                    //If parent changes.
                    if (it.ParentID != id)
                    {
                        if (id != 0)
                        {
                            object target = items[id];
                            if (target is GXAmiCategory)
                            {
                                (target as GXAmiCategory).Properties = list.ToArray();
                            }
                            else if (target is GXAmiDataTable)
                            {
                                (target as GXAmiDataTable).Columns = list.ToArray();
                            }
                        }
                        id = it.ParentID;
                        list.Clear();
                    }
                    list.Add(it);
                }
                if (list.Count != 0 && id != 0)
                {
                    object target = items[id];
                    if (target is GXAmiCategory)
                    {
                        (target as GXAmiCategory).Properties = list.ToArray();
                    }
                    else if (target is GXAmiDataTable)
                    {
                        (target as GXAmiDataTable).Columns = list.ToArray();
                    }
                }

                foreach (GXAmiProperty it in properties)
                {
                    items.Add(it.Id, it);
                }
                items.Add(device.Id, device);
                //Get Parameters.                
                query = string.Format("SELECT * FROM {0} WHERE DeviceID = {1} ORDER BY ParentID, ID",
                                                    GuruxAMI.Server.AppHost.GetTableName<GXAmiParameter>(Db),
                                                    device.Id);
                List<GXAmiParameter> parameters = Db.SqlList<GXAmiParameter>(query);
                id = 0;
                List<GXAmiParameter> paramList = new List<GXAmiParameter>();                
                foreach (GXAmiParameter it in parameters)
                {
                    //If parent changes.
                    if (it.ParentID != id)
                    {
                        if (id != 0)
                        {
                            object target = items[id];
                            if (target is GXAmiDevice)
                            {
                                (target as GXAmiDevice).Parameters = paramList.ToArray();
                            }
                            else if (target is GXAmiCategory)
                            {
                                (target as GXAmiCategory).Parameters = paramList.ToArray();
                            }
                            else if (target is GXAmiDataTable)
                            {
                                (target as GXAmiDataTable).Parameters = paramList.ToArray();
                            }
                            else if (target is GXAmiProperty)
                            {
                                (target as GXAmiProperty).Parameters = paramList.ToArray();
                            }
                            else
                            {
                                throw new Exception("Unknown target.");
//.........这里部分代码省略.........
开发者ID:jomolinare,项目名称:GuruxAMI.Server,代码行数:101,代码来源:GXDeviceService.cs


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