Seguimos buscando a Arshak. Ayudanos compartiendo!
Encuesta no oficial de docentes
Resultados de la encuesta no oficial de docentes
Probaste el SIGA Helper?

Donar $100 Donar $200 Donar $500 Donar mensualmente


Enviar respuesta 
 
Calificación:
  • 1 votos - 4 Media
  • 1
  • 2
  • 3
  • 4
  • 5
Buscar en el tema
Aprender C# .NET
Autor Mensaje
carmen Sin conexión
Militante
2 año ing sistemas
***

Ing. en Sistemas
Facultad Regional Buenos Aires

Mensajes: 58
Agradecimientos dados: 15
Agradecimientos: 34 en 8 posts
Registro en: Nov 2010
Mensaje: #46
RE: Aprender C# .NET



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
//REQUIERE CONEXION A LA FAMOSISIMA BD NORTHWIND POR ESO DA ERROR

namespace W10TIPOSANONIMOS
{
class Program
{
static void Main(string[] args)
{
var t1 = new {ID="1",nombre="C" };
var t2 = new { ID = "1", nombre = "C" };
var soniguales = t1.Equals(t2);//true SOLO COMPARA CONTENIDO

Console.WriteLine("Usando Equals:{0}", soniguales);
Console.ReadLine();
//son instancias distintas
soniguales = (t1 == t2);//false
Console.WriteLine("Usando ==:{0}", soniguales);
Console.ReadLine();
int[] scores = { 90, 71, 82, 93, 75, 82 };
// Query Expression.scoreQuery es la variable de consulta
IEnumerable<int> scoreQuery = //query variable
from score in scores
//required variable de rango score permacece hasta un ; o clausula continuation

where score > 80 // optional
orderby score descending // optional
select score; //must end with select or group

// Execute the query to produce the results
foreach (int testScore in scoreQuery)
{//devuelve valores testScore
Console.WriteLine(testScore);
}
Console.ReadLine();
//no es variable de consulta porque almacena un resultado
int highestScore =
(from score in scores
select score)
.Max();
//usamos varias form si por ejemplo un elemento de la coleccion es origen
//de otra coleccion
/* IEnumerable<City> cityQuery =
from country in countries
from city in country.Cities
where city.Population > 10000
select city;*/
//Group students by the first letter of their last name
// Query variable is an IEnumerable<IGrouping<char, Student>>
/*var studentQuery2 =
from student in students
group student by student.Last[0] into g
orderby g.Key
select g;*/
/*Dado que los objetos IGrouping<TKey,TElement> generados
* por una consulta group son esencialmente una lista de listas,
* debe utilizar un bucle foreach anidado para tener acceso
* a los elementos de cada grupo.El bucle exterior recorre en
* iteración las claves de grupo y el bucle interno recorre en
* iteración cada elemento del propio grupo.Un grupo puede
* tener una clave pero ningún elemento
* .A continuación se muestra el bucle foreach que e
* jecuta la consulta en los ejemplos de código anteriores:
foreach (IGrouping<char, Student> studentGroup in studentQuery2)
{
Console.WriteLine(studentGroup.Key);
// Explicit type for student could also be used here.
foreach (var student in studentGroup)
{
Console.WriteLine(" {0}, {1}", student.Last, student.First);
}
} */
}
}
}



using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


namespace W10LINQINTERNET
{
class Program
{//http://blogs.msdn.com/b/brada/archive/2008/01/29/asp-net-mvc-example-application-over-northwind-with-the-entity-framework.aspx
//http://architecture.ebizassist.com/Home




static void Main(string[] args)
{
List<Person> people = new List<Person>{
new Person{FirstName="Scot1",LastName="Gut1",Age=32},
new Person{FirstName="Scot2",LastName="Gut2",Age=32},
};
IEnumerable<Person> results1 = people.Where(delegate(Person p)
{return p.LastName=="Scot1";
});
IEnumerable<Person> results = from p in people
where p.LastName.StartsWith("S")
select p;
//retorna secuencia de strings
IEnumerable<string> resultsString = from p in people
where p.LastName.StartsWith("S")
select p.LastName;
NorDataContextDataContext db = new NorDataContextDataContext();
IEnumerable<Product> products = from p in db.Product
where p.UnitPrice > 99
select p;
IEnumerable<string> categoriasConCincoProductosAsociados = from c in db.Categorie
where c.Product.Count > 5
select c.CategoryName;

var productHistory = db.CustOrderHist("ALFKI");
foreach (CustOrderHistResult product in productHistory)
{
Console.WriteLine("::::::::::::::::::::");
Console.WriteLine( "Nombre{0},{1}",product.ProductName,product.Total);
Console.WriteLine(product.Total.ToString());

}
Console.ReadKey();

var totalCliente = db.TotalCliente("ALFKI");
Console.WriteLine("Nombre{0},{1}","ALFKI Compro un total de ",totalCliente.ToString());
Console.ReadKey();
//Actualizar un Producto de la base de datos
Product product1 = db.Product.Single(p => p.ProductName == "Tofu");
product1.UnitPrice = 99;
product1.UnitsInStock = 5;
db.SubmitChanges();
//http://speakingin.net/2007/08/27/linq-to-sql-parte-8-ejecutar-consultas-sql-personalizadas/
var partial = db.GetProductByCategory(4);

}

}
}



ALGUNOS EJEMPLOS ANTERIORES TIRAN ERROR PORQUE REQUIEREN REQUIERE DISEÑADOR PARA MAPEAR EL MODELO DE OBJETOS EN LOS VINCULOS ESTO ESTA DETALLADO
(Este mensaje fue modificado por última vez en: 30-01-2016 19:20 por carmen.)
30-01-2016 18:55
Encuentra todos sus mensajes Agregar agradecimiento Cita este mensaje en tu respuesta
carmen Sin conexión
Militante
2 año ing sistemas
***

Ing. en Sistemas
Facultad Regional Buenos Aires

Mensajes: 58
Agradecimientos dados: 15
Agradecimientos: 34 en 8 posts
Registro en: Nov 2010
Mensaje: #47
RE: Aprender C# .NET
[code=csharp]
/*METODOS EXTENSORES INTRODUCCION A LINQ*/
string email = Request.QueryString["email"]
/*Usando métodos de extensión podríamos añadir un método “IsValidEmailAddress()” dentro de la propia clase string, y devolverá cierto o falso dependiendo de si la dirección es válida o no.*/

public static class ScottGuExtensions
{/*“this”, antes que el parámetro de tipo string. Esto le dice al compilador que este método de extensión debe ser añadido a objetos de tipo string*/

public static bool IsValidEmailAddress(this string s)
{
Regex regex = new Regex(@"^[w-.]+@([w-]+.)+[w-]{2,4}$");
return regex.IsMatch(s);
}
}
/*sólo usamos un “using” estándar para importar el namespace que contiene la implementación de los métodos de extensión:
using ScottGuExtensions;*/
02-03-2016 12:40
Encuentra todos sus mensajes Agregar agradecimiento Cita este mensaje en tu respuesta
Buscar en el tema
Enviar respuesta 




Usuario(s) navegando en este tema: 1 invitado(s)