我正在尝试使用dapper的Multimapping功能来返回ProductItems和相关Customers的列表.
[Table("Product")]
public class ProductItem
{
public decimal ProductID { get; set; }
public string ProductName { get; set; }
public string AccountOpened { get; set; }
public Customer Customer { get; set; }
}
public class Customer
{
public decimal CustomerId { get; set; }
public string CustomerName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的短小精悍的代码如下
var sql = @"select * from Product p
inner join Customer c on p.CustomerId = c.CustomerId
order by p.ProductName";
var data = con.Query<ProductItem, Customer, ProductItem>( …Run Code Online (Sandbox Code Playgroud) 我正在使用Entity Framework Code First,我希望能够记录DbContext生成的所有SQL查询.在Linq to sql中有一个DB日志,我似乎无法在EF中找到它.然后我可以将它们放在日志中或输出到页面.
我正在使用EntityFramework Assembly的4.1.0.0版本.
我正在尝试使用带有EFCodeFirst的mvc-mini-profiler我正在创建一个DbProfiledConnection并将其传递给构造中的DbContext,如下所示.应用程序继续按预期工作,sql未向Profiler公开.
public class WebContext : DbContext
{
static DbConnection _connection = new SqlConnection(ConfigurationManager.ConnectionStrings["WebContext"].ConnectionString);
static DbConnection _profiledConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(_connection);
public WebContext()
: base(_profiledConnection, true)
{
}
Run Code Online (Sandbox Code Playgroud)
我糟透了
我已修改它,以便在我的UnitOfWork中构建我的WebContext时,我传入ProfiledDbConnection
public UnitOfWork()
{
var profiledConnection = MvcMiniProfiler.Data.ProfiledDbConnection.Get(connection);
this.context = new MyContext(profiledConnection);
}
Run Code Online (Sandbox Code Playgroud)
我已经检查过并且在Application_BeginRequest中设置了MiniProfier Current,当我尝试查询数据库时,它会返回ProfiledDbConnection,并在ProfiledDbProviderServices类中抛出错误.
protected override string GetDbProviderManifestToken(DbConnection connection)
{
return tail.GetProviderManifestToken(connection);
}
Run Code Online (Sandbox Code Playgroud)
此方法返回"提供程序未返回ProviderManifestToken字符串".错误
asp.net-mvc entity-framework entity-framework-4.1 mvc-mini-profiler
我在我的asp.net MVC 3应用程序上使用mini-profiler.我使用mvc nuget包实现了探查器.一切都适用于标准页面请求我获取配置文件信息sql一切.
但是,最初似乎没有显示ajax请求.只是让我确认请求已经完成而没有错误.我调试了这个,他们完成了他们也在fiddler中返回http 200响应.
ajax请求附带的迷你探查器没有请求.当我然后导航到另一个页面,即标准页面请求时,现在显示在最后一页上进行的所有ajax请求.
这是我在App_Start中的迷你探查器配置页面
public static class MiniProfilerPackage
{
public static void PreStart()
{
//Setup sql formatter
MiniProfiler.Settings.SqlFormatter = new OracleFormatter();
//Make sure the MiniProfiler handles BeginRequest and EndRequest
DynamicModuleUtility.RegisterModule(typeof(MiniProfilerStartupModule));
//Setup profiler for Controllers via a Global ActionFilter
GlobalFilters.Filters.Add(new ProfilingActionFilter());
//Settings
MiniProfiler.Settings.PopupShowTimeWithChildren = true;
MiniProfiler.Settings.PopupShowTrivial = false;
//Ignore glimpse details in miniprofiler
var ignored = MiniProfiler.Settings.IgnoredPaths.ToList();
ignored.Add("Glimpse.axd");
MiniProfiler.Settings.IgnoredPaths = ignored.ToArray();
}
public static void PostStart()
{
// Intercept ViewEngines to profile all partial views and regular …Run Code Online (Sandbox Code Playgroud)