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


C# EntitySet.AddNew方法代码示例

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


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

示例1: OnAddMenuToFavorite

        protected virtual void OnAddMenuToFavorite()
        {
            if (!AllowAddToFavorite) return;

            var es = new EntitySet<sysMyFavoriteMenu>();
            if (!es.TableIsExists()) return;

            es.Query("SELECT TOP 1 * FROM dbo.sysMyFavoriteMenu WITH(NOLOCK) WHERE UserId=:UserId and MenuId=:MenuId", Session.UserInfo.UserId, this.UniqueId);
            if (es.Count <= 0)
            {
                var obj = es.AddNew();
                obj.Iden = IdenGenerator.NewIden(obj.TableName);
                obj.MenuId = Convert.ToInt32(this.UniqueId);
                obj.UserId = Session.UserInfo.UserId;
                obj.RowNumber = 10000;
                es.SaveChanges();
            }

            MessageService.ShowMessage("菜单已经收藏至我的工作台.");

            var shell = ApplicationService.Current.MainForm as IShell;
            if (shell != null)
                shell.RefreshFavorite();

        }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:25,代码来源:BusinessView.cs

示例2: Save

        public void Save()
        {
            var es = new EntitySet<sysAppConfig>();
            es.Query("select * from sysAppConfig with(nolock) where UserId=:UserId", Session.UserInfo.UserId);
            sysAppConfig entity = null;
            if (es.Count <= 0)
            {
                entity = es.AddNew();
                entity.Iden = IdenGenerator.NewIden(entity.TableName);
            }
            else
                entity = es.First();

            entity.UserId = Session.UserInfo.UserId;
            entity.AppConfig = XmlSerializerHelper.Serialize<AppConfig>(this);
            es.SaveChanges();
        }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:17,代码来源:AppConfig.cs

示例3: readXmljp

        private void readXmljp(string filename)
        {
            XmlSerializer xml = new XmlSerializer(typeof(开目信息文件));
            using (var file = new FileStream(filename, FileMode.Open, FileAccess.Read))
            {
                开目信息文件 obj = (开目信息文件)xml.Deserialize(file);

                //MessageBox.Show(obj.数据.元素["产品代号"].Value);//.下级信息[0].数据[0].元素[0].标识

                // MessageBox.Show(obj.数据.元素.FirstOrDefault(p => p.标识 == "产品代号").标识);
                for (int i = 0; i < obj.数据.下级信息[0].数据.Count(); i++)
                {
                    EntitySet<bomRoting> entity = new EntitySet<bomRoting>();
                    entity.Query("select * from  bomRoting with(nolock) where 1=0");
                    bomRoting bm = entity.AddNew();
                    bm.Iden = IdenGenerator.NewIden("bomRoting");
                    bm.BomId = obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value.Substring(0, obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value.IndexOf("-"));
                    bm.BomChildId = string.IsNullOrEmpty(obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value) ? string.Empty : obj.数据.元素.FirstOrDefault(p => p.标识 == "零部组件代号").Value;
                    bm.OpDep = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "生产部门").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "生产部门").Value;
                    bm.RotingId = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序号").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序号").Value;
                    bm.RotingName = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序名称").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序名称").Value;
                    bm.RotingDesc = string.IsNullOrEmpty(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序内容").Value) ? string.Empty : obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工序内容").Value;
                    var Production = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "设备");
                    if (Production == null)
                    {
                        bm.Production = string.Empty;
                    }
                    else
                    {
                        bm.Production = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "设备").Value;
                    } 
                    var RotingProduction=obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工艺装备");
                    if(RotingProduction==null) 
                    {
                        bm.RotingProduction=string.Empty;
                    }
                    else
                    {
                        bm.RotingProduction = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "工艺装备").Value;
                    }

                    var FZMeterial = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "辅助材料");
                    if (FZMeterial == null)
                    {
                        bm.FZMeterial = string.Empty;
                    }
                    else
                    {
                        bm.FZMeterial = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "辅助材料").Value;
                    } 
                   
                    var ZhunJie = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "准结");
                    if (ZhunJie == null)
                    {
                        bm.ZhunJie =0;
                    }
                    else
                    {
                        bm.ZhunJie =Convert.ToDecimal(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "准结").Value);
                    } 
                   var DanJian = obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "单件");
                    if (DanJian == null)
                    {
                        bm.DanJian = 0;
                    }
                    else
                    {
                        bm.DanJian = Convert.ToDecimal(obj.数据.下级信息[0].数据[i].元素.FirstOrDefault(p => p.标识 == "单件").Value);
                    } 
                    if (isExportBomRoting(bm.BomId, bm.BomChildId, bm.RotingId))
                        continue;
                    entity.SaveChanges();
                }


            }
        }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:77,代码来源:bomRotingView.cs

示例4: InitMyWorkspace

        private void InitMyWorkspace()
        {
            myMenuEntitySet = this.MainEntitySet.Clone() as EntitySet<sysMenu>;
            var root = myMenuEntitySet.AddNew();
            root.Iden = -1;
            root.ParentId = -2;
            root.Name = "我收藏的菜单";
            root.MenuOrder = -1;

            MyFavoriteMenu.Query("SELECT a.Iden, a.MenuId,RowNumber FROM dbo.sysMyFavoriteMenu a with(nolock) WHERE UserId=:UserId", Session.UserInfo.UserId);

            var list = this.MainEntitySet.Where(p => MyFavoriteMenu.Any(x => x.MenuId == p.Iden));

            foreach (var item in list)
            {
                var obj = myMenuEntitySet.AddNew();
                obj.Copy(item);
                obj.ParentId = root.Iden;
                obj.MenuOrder = MyFavoriteMenu.First(p => p.MenuId == item.Iden).RowNumber;
                obj.MenuType = (int)sysMenuType.Menu;
            }

            this.treeMyMenu.OptionsBehavior.AutoPopulateColumns = false;
            this.treeMyMenu.OptionsBehavior.Editable = false;
            if (this.treeMyMenu.Columns.ColumnByFieldName("Name") == null)
            {
                var colName = this.treeMyMenu.Columns.Add();
                colName.Caption = "名称";
                colName.FieldName = "Name";
                colName.Name = "colName";
                colName.OptionsColumn.AllowEdit = false;
                colName.OptionsColumn.AllowMove = false;
                colName.OptionsColumn.AllowMoveToCustomizationForm = false;
                colName.OptionsColumn.AllowSort = false;
                colName.OptionsColumn.ReadOnly = true;
                colName.OptionsColumn.ShowInCustomizationForm = false;
                colName.OptionsColumn.ShowInExpressionEditor = false;
                colName.OptionsFilter.AllowAutoFilter = false;
                colName.OptionsFilter.AllowFilter = false;
                colName.Visible = true;
                colName.VisibleIndex = 0;
            }

            var source = myMenuEntitySet.OrderBy(p => p.ParentId).OrderBy(p => p.MenuOrder).OrderBy(p => p.Iden);
            this.treeMyMenu.DataSource = new BindingSource() { DataSource = source.Select(p => p.DataRowView) };
            this.treeMyMenu.KeyFieldName = "Iden";
            this.treeMyMenu.ParentFieldName = "ParentId";
            this.treeMyMenu.ExpandAll();
        }
开发者ID:JodenSoft,项目名称:JodenSoft,代码行数:49,代码来源:Shell.cs


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