91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

linq關系映射(1)

發布時間:2020-07-07 11:10:01 來源:網絡 閱讀:329 作者:Aonaufly 欄目:編程語言

linq關系映射(1)

C#的這種entity 很像Annotation java的寫法..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Data.Linq.Mapping;
namespace LinqObject.models
{
    [Table(Name = "Player")]
    public class PlayerInfoVO
    {
                         
        private string name;
        [Column(Name="name")]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
                         
        private int id;
        [Column(IsPrimaryKey=true,Name="id")]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }
                         
        private int level;
        [Column(Name = "level_id")]
        public int Level
        {
            get { return level; }
            set { level = value; }
        }
        private EntityRef<MyLevel> _myLevel;
        [Association(Storage="_myLevel",ThisKey="level_id")]
        public EntityRef<MyLevel> _MyLevel
        {
            get { return _myLevel; }
            set { _myLevel = value; }
        }
    }
}

主表:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Linq;
using System.Data.Linq.Mapping;
namespace LinqObject.models{
    [Table(Name="myLevel")]
    public class MyLevel{
        private int id;
        [Column(IsPrimaryKey=true,Name="id")]
        public int Id
        {
            get { return id; }
            set { id = value; }
        }
        private string name;
        [Column(Name="name")]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        private EntitySet<PlayerInfoVO> player;
        [Association(Storage = "player", OtherKey = "Id")]
        public EntitySet<PlayerInfoVO> Player
        {
            get { return player; }
            set { player = value; }
        }
                     
    }
}

刪除 操作 :

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using LinqObject.models;
namespace LinqObject.mylinq{
    public class ConflictLinq{
        public void updatePlayer(int id, string name) {
            AINYLinq db = new AINYLinq(@"Data Source=AONAUFLY\SQLEXPRESS;Initial Catalog=MyLINQ;User ID=sa;Password=******");
            IQueryable<MyLevel> myList = from o in db.myLevel
                         where o.Id == 0 && o.Name == "Aonaufly"
                         select o;
            foreach (var o in myList) {
                Console.WriteLine("Ainy------------------------");
                db.myLevel.DeleteOnSubmit(o);
            }
            Console.WriteLine("detail section finished.");
            Console.ReadLine();
            if (myList.Any())
            {
                Console.WriteLine("The parent is presesnt in the Orders collection.");
                try
                {
                    var ordF = (from o in db.myLevel
                                where o.Id == 0
                                select o).First();
                    db.myLevel.DeleteOnSubmit(ordF);
                    Console.WriteLine(ordF.Name);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                    Console.ReadLine();
                }
            }
            else {
                Console.WriteLine("There was no parent in the myLevel");
            }
            try
            {
                db.SubmitChanges();
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
                Console.ReadLine();
            }
        }
    }
}


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

乐清市| 大方县| 华池县| 鞍山市| 建湖县| 化州市| 松江区| 平遥县| 荥经县| 济宁市| 利辛县| 屯门区| 大冶市| 健康| 洪江市| 丹凤县| 紫金县| 米泉市| 鄱阳县| 天等县| 财经| 巴林左旗| 曲阜市| 巴南区| 汶川县| 牟定县| 河津市| 承德县| 新巴尔虎右旗| 读书| 凯里市| 确山县| 上犹县| 泰州市| 巴林右旗| 神木县| 丰都县| 苍南县| 景泰县| 柳州市| 平泉县|