2
내 MVC3 응용 프로그램에서 Dapper와 EF 4를 함께 사용하고 싶습니다. 둘 이상의 프로파일 연결을 가질 수 있습니까? 아니면 프로파일 연결을 공유합니까?MVC 미니 프로파일 러와 프로파일 링 된 연결을 둘 이상 가질 수 있습니까?
내 MVC3 응용 프로그램에서 Dapper와 EF 4를 함께 사용하고 싶습니다. 둘 이상의 프로파일 연결을 가질 수 있습니까? 아니면 프로파일 연결을 공유합니까?MVC 미니 프로파일 러와 프로파일 링 된 연결을 둘 이상 가질 수 있습니까?
예, Dapper와 EF 프로파일 연결을 사용할 수 있습니다. 사용 방법은 다음과 같습니다.
private static DatabaseContext GetDatabaseContext()
{
using (MiniProfiler.Current.Step("Create Oracle EF Context"))
{
var pConn = ProfiledConnection;
return pConn.CreateObjectContext<DatabaseContext>();
}
}
private static EFProfiledDbConnection ProfiledConnection
{
get
{
using (MiniProfiler.Current.Step("Create Oracle Profiled Connection"))
{
var connectionString =
ConfigurationManager.ConnectionStrings["DatabaseContext"].ConnectionString;
var ecsb = new EntityConnectionStringBuilder(connectionString);
var oraConn = new OracleConnection(ecsb.ProviderConnectionString);
var pConn = new EFProfiledDbConnection(oraConn, MiniProfiler.Current);
return pConn;
}
}
}
은 그 때 나는이 방법
using (var ctx = GetDatabaseContext())
{
var result = ctx.SOME_EF_ENTITY.FirstOrDefault(c => c.LOGINNAME == username && c.PASSWORD == password);
return result;
}
및
const string sql = @"
SELECT ppro_status_code_id
FROM ppro_status_codes
WHERE table_name = 'CLIENT_FC_SHARED'
AND status_code = :status_code";
using (var cnn = ProfiledConnection)
{
cnn.Open();
var data = cnn.Query<dynamic>(sql, new { status_code = code });
var result = data.First();
var codeID = result.PPRO_STATUS_CODE_ID;
return codeID;
}
당신이 질문을 명확히 할 수 그들을 사용? 원하는만큼 프로파일 연결을 할 수 있습니다 ... –