本文整理匯總了C#中Service.List.ToList方法的典型用法代碼示例。如果您正苦於以下問題:C# List.ToList方法的具體用法?C# List.ToList怎麽用?C# List.ToList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Service.List
的用法示例。
在下文中一共展示了List.ToList方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: SaveUploadedFile
public ActionResult SaveUploadedFile(string id)
{
bool isSavedSuccessfully = true;
string fName = "";
string fileName1 = "";
string fileExtension = "";
string pathFile = "";
DataTable ds = new DataTable();
try
{
foreach (string fileName in Request.Files)
{
HttpPostedFileBase file = Request.Files[fileName];
fName = file.FileName;
fileExtension = System.IO.Path.GetExtension(Request.Files["file"].FileName);
if (file != null && file.ContentLength > 0 && (file.FileName.EndsWith("xls") || file.FileName.EndsWith("xlsx")))
{
var originalDirectory = new DirectoryInfo(string.Format("{0}Fichiers", Server.MapPath(@"\")));
string pathString = System.IO.Path.Combine(originalDirectory.ToString(), "Exels");
fileName1 = Path.GetFileName(file.FileName);
bool isExists = System.IO.Directory.Exists(pathString);
if (!isExists)
System.IO.Directory.CreateDirectory(pathString);
pathFile = string.Format("{0}\\{1}", pathString, file.FileName);
file.SaveAs(pathFile);
}
else
{
ViewBag.Error = "Selectionner un fichier Excel SVP !!!";
return View("Index");
}
}
}
catch (Exception ex)
{
isSavedSuccessfully = false;
}
if (isSavedSuccessfully)
{
List<Bien> list = new List<Bien>();
ds = ExcelParser.Instance.ExcelParserToDataTable(pathFile, null);
foreach (DataRow row in ds.Rows)
{
Bien catalogue = new Bien();
//catalogue.Code_a_barre = Convert.ToInt32(row["Code matériel "]);
catalogue.Num_Serie = row["N° de série "].ToString();
///var i = db.FindCategorie_materielByNom(row["Catégorie "].ToString());
//catalogue.Categorie_materiel = Convert.ToString(i.Id_Categorie_materiel);
catalogue.Modele = row["Modèle "].ToString();
catalogue.Marque = row["Marque "].ToString();
catalogue.Etat = row["Statut "].ToString();
//catalogue.Fin_garantie = Convert.ToDateTime(row["Fin de garantie "]);
catalogue.Id_etage = Convert.ToInt32(row["Localisation (dernier niveau) "]);
catalogue.idBatiment = Convert.ToInt32(row["Entité (dernier niveau) "]);
//catalogue.Date_d_inventaire = Convert.ToDateTime(row["Date inventaire "]);
catalogue.Date_d_installation = Convert.ToDateTime(row["Date d'installation "]);
catalogue.idBatiment = Convert.ToInt32(row["Localisation (complet) "]);
//catalogue.id_direction = Convert.ToInt32(row["Entité (complet) "]);
//catalogue.Code_materiel.ToString() = Code;
list.Add(catalogue);
BissInventaireEntities.Instance.Bien.Add(catalogue);
BissInventaireEntities.Instance.SaveChanges();
}
Session["Tesst"] = list.ToList();
return View("Create1");
}
return HttpNotFound();
}