티스토리 뷰
Entity Framework(DbContext & C#만으로 구현)-.edmx 파일 생성하지 않음.
James Wetzel 2018. 12. 12. 16:591. Entity Framework 설치
2. Web.config 설정
<connectionStrings>
<add name="shipConnectionString" connectionString="Data Source=0.0.0.0,3750;Initial Catalog=databaseName;User ID=id;Password=123456" providerName="System.Data.SqlClient"/>
</connectionStrings>
3. DbContext 클래스 생성(ShipDbContext)
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Linq;
namespace WebApplication.ORM
{
public class ShipDbContext : DbContext
{
public ShipDbContext() : base("name=shipConnectionString")
{
//Disable initializer
Database.SetInitializer<ShipDbContext>(null);
}
public virtual IList<QprimeTypeListEntity> GetQprimeTypeList(string svc_nation_cd)
{
SqlParameter[] sqlParameters = new SqlParameter[] {
new SqlParameter("svc_nation_cd", svc_nation_cd)
};
return this.Database.SqlQuery<QprimeTypeListEntity>("Qprime_SelectListQprimeType @svc_nation_cd", sqlParameters).ToList<QprimeTypeListEntity>();
}
}
}
4. Entity 클래스 생성
using System;
namespace WebApplication.ORM
{
public class QprimeTypeListEntity
{
public Nullable<int> Id { get; set; }
public string TypeName { get; set; }
}
}
5. Controller 생성 및 호출
using System.Collections.Generic;
using System.Web.Mvc;
using WebApplication.ORM;
namespace WebApplication.Controllers
{
public class HomeController : Controller
{
// GET: Home
public ActionResult Index()
{
ShipDbContext shipDbContext = new ShipDbContext();
IList<QprimeTypeListEntity> qprimeTypeListEntities = shipDbContext.GetQprimeTypeList("US");
return View();
}
}
}
- Total
- Today
- Yesterday
- html tag
- trim
- .submit()
- 공백제거
- In App Purchase
- nl2br
- Task
- MainActor
- 특정 문자를 기준으로 자르기
- 명령어
- system.io
- async
- 상품 등록
- App Store
- mssql
- 제품 등록
- 진수 변환
- 앱 스토어
- System.Diagnostics
- await
- 문자 자르기
- hyper-v
- 아이폰
- FileUpload
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | 6 | |
7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 | 15 | 16 | 17 | 18 | 19 | 20 |
21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 | 29 | 30 |