28 Ekim 2014 Salı

C# Entity db Update işlemi

Metod 1:
var original = db.Users.Find(updatedUser.UserId);

if (original != null)
{
    original.BusinessEntityId = updatedUser.BusinessEntityId;
    original.Email = updatedUser.Email;
    original.EmployeeId = updatedUser.EmployeeId;
    original.Forename = updatedUser.Forename;
    original.Surname = updatedUser.Surname;
    original.Telephone = updatedUser.Telephone;
    original.Title = updatedUser.Title;
    original.Fax = updatedUser.Fax;
    original.ASPNetUserId = updatedUser.ASPNetUserId;
    db.SaveChanges();
}    

Metod 2:

var original = db.Users.Find(updatedUser.UserId);

if (original != null)
{
    db.Entry(original).CurrentValues.SetValues(updatedUser);
    db.SaveChanges();
}
Metod 3 

db.Users.Attach(updatedUser);
db.Entry(updatedUser).State = EntityState.Modified;
db.SaveChanges();


Alternatif :
(from x in dataBase.Customers
         where x.Name == "Test"
         selext x).ToList().ForEach(xx => x.Name="New Name");


24 Ekim 2014 Cuma

java cache sıfırlama

/util/cache-manager?cacheCommand=EVICT_ALL_CACHE

23 Ekim 2014 Perşembe

sqlplus ve C# ile oracle db baglantı

sqlplus system@"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=xxx.xxx.xxx.xxx)(PORT=1521))(CONNECT_DATA=(SID=xxxxxxxx)))"


C# Oracle DB Baglantı :


         
OracleConnection con = new OracleConnection();

  //using connection string attributes to connect to Oracle Database

con.ConnectionString = "User Id=SIS_SW;Password=xxx;Data Source="
+ "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)"
+ "(HOST=xxxx)(PORT=1521))(CONNECT_DATA="
+ "(SERVICE_NAME=xxxx)))";

con.Open();

                // Close and Dispose OracleConnection object
             
 con.Close();
 con.Dispose();