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


C# List.CopyTo方法代码示例

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


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

示例1: search

 public static List<Kitap> search(string kitapAdi, Yazar[] yazarlar, int[] yillar)
 {
     List<Kitap> Value = new List<Kitap>();
     SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
     String CommandString = "select ID,Adi,BasimYili,YayineviID,KategoriID,SayfaSayisi,HasarDurumu,KiralamaDurumu,Ucret,Ozet,Kapak ";
     CommandString += "from dbo.Kitap join dbo.KitapYazar on dbo.Kitap.ID = dbo.KitapYazar.KitapID where ";
     CommandString += "(Adi like '%" + kitapAdi + "%') and (";
     int counter = 0;
     foreach (Yazar item in yazarlar)
     {
         if (item.ID != 0)
         {
             CommandString += "dbo.KitapYazar.YazarID=" + item.ID.ToString() + " or ";
             counter++;
         }
     }
     if (counter > 0)
     {
         CommandString = CommandString.Remove(CommandString.Length - 4);
         CommandString += ") and (";
     }
     foreach (int item in yillar)
     {
         CommandString += "dbo.Kitap.BasimYili='" + item.ToString() + "' or ";
     }
     CommandString = CommandString.Remove(CommandString.Length - 4);
     CommandString += ")";
     SqlCommand cmd = new SqlCommand(CommandString, con);
     con.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     while (reader.Read())
     {
         int id = reader.GetInt32(0);
         SqlConnection AuthorCon = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
         SqlCommand AuthorCmd = new SqlCommand("select YazarID from dbo.KitapYazar where KitapID = " + id.ToString(), AuthorCon);
         AuthorCon.Open();
         SqlDataReader AuthorReader = AuthorCmd.ExecuteReader();
         List<Yazar> YazarList = new List<Yazar>();
         while (AuthorReader.Read())
         {
             YazarList.Add(YazarIslemleri.getAuthor(AuthorReader.GetInt32(0)));
         }
         AuthorReader.Close();
         AuthorCon.Close();
         Yazar[] Yazarlar = null;
         if (YazarList.Count > 0)
         {
             Yazarlar = new Yazar[YazarList.Count];
             YazarList.CopyTo(Yazarlar);
         }
         Yayinevi Publisher = YayineviIslemleri.getPublisher(reader.GetInt32(3));
         Kategori Category = KategoriIslemleri.getCategory(reader.GetInt32(4));
         Kitap Current = new Kitap(id, reader.GetString(1), int.Parse(reader.GetString(2)), Yazarlar, Publisher, Category,
             reader.GetInt32(5), reader.GetBoolean(7), reader.GetBoolean(6), reader.GetDecimal(8));
         try
         {
             Current.Ozet = reader.GetString(9);
         }
         catch (SqlNullValueException snve)
         {
             Current.Ozet = "";
         }
         try
         {
             Current.Kapak = reader.GetString(10);
         }
         catch (SqlNullValueException snve)
         {
             Current.Kapak = "";
         }
         if (!Value.Contains(Current))
         {
             Value.Add(Current);
         }
     }
     reader.Close();
     con.Close();
     return Value;
 }
开发者ID:ErelOzcakirlar,项目名称:KutuphaneOtomasyon,代码行数:79,代码来源:KitapIslemleri.cs

示例2: mostRentedBook

 public static List<Kitap> mostRentedBook(DateTime First, DateTime Last)
 {
     List<Kitap> Value = new List<Kitap>();
     SqlConnection con = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
     String CommandString = "select KitapID,COUNT(KitapID) as KiralamaSayisi from dbo.Kiralama" +
         " join dbo.KiralamaDetay on Kiralama.ID = KiralamaDetay.ID" +
         " where KiralamaDetay.KiralamaTarihi between";
     CommandString += " '" + convertToSqlDate(First.ToShortDateString()) + "' and";
     CommandString += " '" + convertToSqlDate(Last.ToShortDateString()) + "' group by KitapID";
     CommandString += " order by KiralamaSayisi desc";
     SqlCommand cmd = new SqlCommand(CommandString, con);
     con.Open();
     SqlDataReader reader = cmd.ExecuteReader();
     int max = 0;
     List<int> Kitaplar = new List<int>();
     if (reader.Read())
     {
         max = reader.GetInt32(1);
         Kitaplar.Add(reader.GetInt32(0));
     }
     while (reader.Read())
     {
         int currentCount = reader.GetInt32(1);
         if (currentCount == max)
         {
             Kitaplar.Add(reader.GetInt32(0));
         }
         else if (currentCount < max)
         {
             break;
         }
     }
     reader.Close();
     con.Close();
     if (Kitaplar.Count > 0)
     {
         CommandString = "select * from dbo.Kitap where ";
         foreach (int item in Kitaplar)
         {
             CommandString += "ID=" + item.ToString() + " or ";
         }
         CommandString = CommandString.Remove(CommandString.Length - 4);
         cmd = new SqlCommand(CommandString, con);
         con.Open();
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             int id = reader.GetInt32(0);
             SqlConnection AuthorCon = new SqlConnection("Server=.;Database=KutuphaneOtomasyon;Trusted_Connection=true");
             SqlCommand AuthorCmd = new SqlCommand("select YazarID from dbo.KitapYazar where KitapID = " + id.ToString(), AuthorCon);
             AuthorCon.Open();
             SqlDataReader AuthorReader = AuthorCmd.ExecuteReader();
             List<Yazar> YazarList = new List<Yazar>();
             while (AuthorReader.Read())
             {
                 YazarList.Add(YazarIslemleri.getAuthor(AuthorReader.GetInt32(0)));
             }
             AuthorReader.Close();
             AuthorCon.Close();
             Yazar[] Yazarlar = null;
             if (YazarList.Count > 0)
             {
                 Yazarlar = new Yazar[YazarList.Count];
                 YazarList.CopyTo(Yazarlar);
             }
             Yayinevi Publisher = YayineviIslemleri.getPublisher(reader.GetInt32(3));
             Kategori Category = KategoriIslemleri.getCategory(reader.GetInt32(4));
             Kitap Current = new Kitap(id, reader.GetString(1), int.Parse(reader.GetString(2)), Yazarlar, Publisher, Category,
                 reader.GetInt32(5), reader.GetBoolean(7), reader.GetBoolean(6), reader.GetDecimal(8));
             try
             {
                 Current.Ozet = reader.GetString(9);
             }
             catch (SqlNullValueException snve)
             {
                 Current.Ozet = "";
             }
             try
             {
                 Current.Kapak = reader.GetString(10);
             }
             catch (SqlNullValueException snve)
             {
                 Current.Kapak = "";
             }
             if (!Value.Contains(Current))
             {
                 Value.Add(Current);
             }
         }
         reader.Close();
         con.Close();
     }
     return Value;
 }
开发者ID:ErelOzcakirlar,项目名称:KutuphaneOtomasyon,代码行数:95,代码来源:RaporIslemleri.cs


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