daily pastebin goal
1%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 46 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using (Entities context = new Entities())
  2. {
  3.     context.MyStoreadProcedure(Parameters);
  4. }
  5.    
  6. sqlStr = "CALL updateGame(?,?,?,?,?,?,?)";
  7.  
  8. commandObj = new OdbcCommand(sqlStr, mainConnection);
  9. commandObj.Parameters.Add("@id,", OdbcType.Int).Value = inGame.id;
  10. commandObj.Parameters.Add("@name", OdbcType.VarChar, 255).Value = inGame.name;
  11. commandObj.Parameters.Add("@description", OdbcType.Text).Value = ""; //inGame.description;
  12. commandObj.Parameters.Add("@yearPublished", OdbcType.DateTime).Value = inGame.yearPublished;
  13. commandObj.Parameters.Add("@minPlayers", OdbcType.Int).Value = inGame.minPlayers;
  14. commandObj.Parameters.Add("@maxPlayers", OdbcType.Int).Value = inGame.maxPlayers;
  15. commandObj.Parameters.Add("@playingTime", OdbcType.VarChar, 127).Value = inGame.playingTime;    
  16.  
  17. return Convert.ToInt32(executeScaler(commandObj));
  18.    
  19. CREATE DEFINER=`106228`@`%` PROCEDURE `updateGame`(
  20.  
  21. inId INT,
  22.  
  23. inName VARCHAR(255),
  24.  
  25. inDescription TEXT,
  26.  
  27. inYearPublished DATETIME,
  28.  
  29. inMinPlayers INT,
  30.  
  31. inMaxPlayers INT,
  32.  
  33. inPlayingTime VARCHAR(127)
  34.  
  35. )
  36.    
  37. SqlParameter param1 = new SqlParameter("@firstName", "Frank");
  38. SqlParameter  param2 = new SqlParameter("@lastName", "Borland");
  39. context.Database.ExecuteSqlCommand("sp_MyStoredProc @firstName, @lastName",
  40.                               param1, param2);
  41.    
  42. var oficio= new SqlParameter
  43. {
  44.     ParameterName = "pOficio",
  45.     Value = "0001"
  46. };
  47.  
  48. using (var dc = new PCMContext())
  49. {
  50.     return dc.Database
  51.              .SqlQuery<ProyectoReporte>("exec SP_GET_REPORTE @pOficio",
  52.                                         oficio)
  53.              .ToList();
  54. }
  55.    
  56. using (Entities context = new Entities())
  57. {
  58.     context.MyStoreadProcedure(Parameters);
  59. }
  60.    
  61. using (testentities te = new testentities())
  62. {
  63.     //-------------------------------------------------------------
  64.     // Simple stored proc
  65.     //-------------------------------------------------------------
  66.     var parms1 = new testone() { inparm = "abcd" };
  67.     var results1 = te.CallStoredProc<testone>(te.testoneproc, parms1);
  68.     var r1 = results1.ToList<TestOneResultSet>();
  69. }
  70.    
  71. [TestClass]
  72. public class TenantDataBasedTests : BaseIntegrationTest
  73. {
  74.     [TestMethod]
  75.     public void GetTenantForName_ReturnsOneRecord()
  76.     {
  77.         // ARRANGE
  78.         const int expectedCount = 1;
  79.         const string expectedName = "Me";
  80.  
  81.         // Build the paraemeters object
  82.         var parameters = new GetTenantForTenantNameParameters
  83.         {
  84.             TenantName = expectedName
  85.         };
  86.  
  87.         // get an instance of the stored procedure passing the parameters
  88.         var procedure = new GetTenantForTenantNameProcedure(parameters);
  89.  
  90.         // Initialise the procedure name and schema from procedure attributes
  91.         procedure.InitializeFromAttributes();
  92.  
  93.         // Add some tenants to context so we have something for the procedure to return!
  94.         AddTenentsToContext(Context);
  95.  
  96.         // ACT
  97.         // Get the results by calling the stored procedure from the context extention method
  98.         var results = Context.ExecuteStoredProcedure(procedure);
  99.  
  100.         // ASSERT
  101.         Assert.AreEqual(expectedCount, results.Count);
  102.     }
  103. }
  104.  
  105. internal class GetTenantForTenantNameParameters
  106. {
  107.     [Name("TenantName")]
  108.     [Size(100)]
  109.     [ParameterDbType(SqlDbType.VarChar)]
  110.     public string TenantName { get; set; }
  111. }
  112.  
  113. [Schema("app")]
  114. [Name("Tenant_GetForTenantName")]
  115. internal class GetTenantForTenantNameProcedure
  116.     : StoredProcedureBase<TenantResultRow, GetTenantForTenantNameParameters>
  117. {
  118.     public GetTenantForTenantNameProcedure(
  119.         GetTenantForTenantNameParameters parameters)
  120.         : base(parameters)
  121.     {
  122.     }
  123. }
  124.    
  125. public List<CumulativeInstrumentsDataRow> GetCumulativeInstrumentLogs(RunLogFilter filter)
  126.     {
  127.         EFDbContext db = new EFDbContext();
  128.         if (filter.SystemFullName == string.Empty)
  129.         {
  130.             filter.SystemFullName = null;
  131.         }
  132.         if (filter.Reconciled == null)
  133.         {
  134.             filter.Reconciled = 1;
  135.         }
  136.         string sql = GetRunLogFilterSQLString("[dbo].[rm_sp_GetCumulativeInstrumentLogs]", filter);
  137.         return db.Database.SqlQuery<CumulativeInstrumentsDataRow>(sql).ToList();
  138.     }
  139.    
  140. public string GetRunLogFilterSQLString(string procedureName, RunLogFilter filter)
  141.         {
  142.             return string.Format("EXEC {0} {1},{2}, {3}, {4}", procedureName, filter.SystemFullName == null ? "null" : "'" + filter.SystemFullName + "'", filter.MinimumDate == null ? "null" : "'" + filter.MinimumDate.Value + "'", filter.MaximumDate == null ? "null" : "'" + filter.MaximumDate.Value + "'", +filter.Reconciled == null ? "null" : "'" + filter.Reconciled + "'");
  143.  
  144.         }
  145.    
  146. using (var ctx = new SchoolDBEntities())
  147.         {
  148.             Student stud = new Student();
  149.             stud.StudentName = "New sp student";
  150.             stud.StandardId = 262;
  151.  
  152.             ctx.Students.Add(stud);
  153.             ctx.SaveChanges();
  154.         }
RAW Paste Data
Top