我正在使用ASP.NET Webforms + EF4开始一个新的Web项目.我正在尝试按照本教程应用具有工作单元模式的存储库模式:http://www.dotnetage.com/publishing/home/2011/07/05/6883/the-repository-pattern-with-ef -code先dependeny喷射在-ASP净mvc3.html
我想我有了这个想法,但我的问题是,当我在模型中创建一个新对象时,我是否还必须在工作单元的IDALContext中定义该对象?这不是一个快速发展的手?此外,如果您与多个开发人员合作,并且如果您不希望其他开发人员看到您的DAL,您如何管理它?因为在我理解的模式中,当您在模型中创建新对象时,您还必须在本教程的IDALContext中定义它.对不起,我很困惑.
我正在尝试注册一个名为"BigEye.Business"的DLL并将该文件引用到mvc 3项目.但是当我尝试在该dll中获取对象的实例时,autofac表示它没有注册.这是我如何注册和解决对象:
private static IContainer SetDIContainer()
{
var builder = new ContainerBuilder();
builder.RegisterControllers(Assembly.GetExecutingAssembly());
builder.RegisterType<UserAuthManager>().As<IUserAuth>().InstancePerHttpRequest();
builder.RegisterType<SessionManager>().As<ISession>().InstancePerHttpRequest();
//Here is the code to register that dll
var services = Assembly.Load("BigEye.Business");
builder.RegisterAssemblyTypes(services);
IContainer container = builder.Build();
DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
return container;
}
public static T GetInstance<T>()
{
IContainer container = SetDIContainer();
using(var httpRequestScope = container.BeginLifetimeScope("httpRequest"))
{
return httpRequestScope.Resolve<T>();
}
}
Run Code Online (Sandbox Code Playgroud)
当我调用GetInstance函数时,我得到"请求的服务'BigEye.Interfaces.Business.IUser'尚未注册".我应该注册Business dll中的所有组件吗?有办法吗?因为Business中的对象和服务会及时发生变化.
谢谢
我有一个使用 Webpack 4 的项目。我使用文件加载器来处理 html 中的图像和样式中的字体。但对于图像,文件加载器在 dist 文件夹中创建图像,但放置“module.exports = __webpack_public_path__ +“assets/fonts/main-logo.svg”;” 字符串在其中。所以我可以在 html 中看到正确的路径,但看不到图像。这是我的 webpack 文件:
const path = require('path');
module.exports = {
entry: "./src/index.js",
module: {
rules: [
{
test: /\.html$/,
use: ["html-loader"]
},
{
test: /\.(svg|png|jpg|gif)$/,
use: {
loader: "file-loader",
options: {
esModule: false,
name: "[name].[ext]",
outputPath: "assets/images"
}
}
},
{
test: /\.(woff(2)?|ttf|eot|svg)([\?]?.*)?$/,
exclude: /node_modules/,
use: {
loader: "file-loader",
options: {
esModule: false,
name: "[name].[ext]",
outputPath: "assets/fonts"
}
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
这是开发环境的webpack.dev.js文件。 …
我想获得浏览器打开的操作系统版本,实际上我的项目是一个asp.net项目,我想知道哪个操作系统在客户端上运行但是有一个问题.因为客户端将使用xp,但同时将使用Windows CE 5.0,因此Windows CE中的Internet Explorer不如xp中的那个好,因为它我会将用户重定向到我为之设计的页面Windows CE.那么有什么办法可以解决这个问题吗?
谢谢..
我尝试使用CarrierWave上传文件,Image模型是多态的.但我得到了标题中的错误,所以这是我的模型:
class Image < ActiveRecord::Base
belongs_to :imageable, polymorphic: true
mount_uploader :image, ImageUploader
enum image_type: {icon: 1, title: 2, regular: 3, slider: 4}
end
class Service < ActiveRecord::Base
has_many :images, as: :imageable, :dependent => :destroy
accepts_nested_attributes_for :images
end
Run Code Online (Sandbox Code Playgroud)
和_form.html.erb:
<div class="control-group">
<%= simple_fields_for :images do |image| %>
<div class="controls">
<label class="control-label">Hizmet Büyük Resimi</label>
<div class="fileupload fileupload-new" data-provides="fileupload">
<div class="fileupload-new thumbnail" style="width: 200px; height: 150px;"><img src="http://www.placehold.it/200x150/EFEFEF/AAAAAA&text=no+image" alt=""/></div>
<div class="fileupload-preview fileupload-exists thumbnail" style="max-width: 200px; max-height: 150px; line-height: 20px;"></div>
<div>
<span class="btn btn-file"><span class="fileupload-new">Resim …Run Code Online (Sandbox Code Playgroud) ruby-on-rails image-uploading nested-attributes carrierwave ruby-on-rails-4
我做了一个List来保存对象,然后我会读它.但即使我给List一个索引,我总是得到相同的对象结果.这是代码:
List<TempIds> treeDIds = new List<TempIds>();
TempIds tempIds = new TempIds();
foreach (ItemGroupTreeD treeD in itemTreeDColl)
{
//Idleri listeye al?yoruz daha sonra kar??la?t?rma yapmak için
tempIds.TreeDId = treeD.Id;
tempIds.TreeParentId = treeD.TreeParentId;
treeDIds.Insert(treeDIds.Count, tempIds);
//----
//E?er ilk gelen detay id ile methoda gelen id bir ise collectiona ekliyoruz.
if (tempIds.TreeDId == groupTreeDId)
{
treeDTempColl.Add(treeD);
}
else
{
//Burada kar??la?t?rma yap?yoruz.
for (int i = 0; i < treeDIds.Count; i++)
{
if (tempIds.TreeParentId == treeDIds[i].TreeDId)
{
treeDTempColl.Add(treeD);
break;
}
}
}
} …Run Code Online (Sandbox Code Playgroud) 我正在使用Entite Framework 4.2 CF和SQLite,但是当我尝试启动应用程序时,我得到"提供程序不支持CreateDatabase"错误.这是我的模型映射:
protected override void OnModelCreating(DbModelBuilder modelBuilder)
{
#region NewsMapping
modelBuilder.Entity<News>().ToTable("news");
modelBuilder.Entity<News>().HasKey(x => x.Id).Property(x => x.Id).HasColumnName("ID").HasColumnOrder(0);
modelBuilder.Entity<News>().Property(x => x.Status).HasColumnName("STATUS");
modelBuilder.Entity<News>().Property(x => x.NewsTitle).HasColumnName("NEWS_TITLE");
modelBuilder.Entity<News>().Property(x => x.Content).HasColumnName("CONTENT_1");
modelBuilder.Entity<News>().Property(x => x.IsImportant).HasColumnName("IS_IMPORTANT");
modelBuilder.Entity<News>().Property(x => x.OrderNumber).HasColumnName("ORDER_NUMBER");
modelBuilder.Entity<News>().Property(x => x.CreateDate).HasColumnName("CREATE_DATE");
#endregion
base.OnModelCreating(modelBuilder);
}
Run Code Online (Sandbox Code Playgroud)
这段代码有什么问题?
谢谢
sqlite system.data.sqlite ef-code-first entity-framework-4.1 asp.net-mvc-3
我正在尝试在我的项目中使用autofac.所以在Mef中,我可以使用此代码获取接口的实例:
private static CompositionContainer _container;
public static void Initialize()
{
string path = AppDomain.CurrentDomain.BaseDirectory.Contains(@"\bin") ?
AppDomain.CurrentDomain.BaseDirectory :
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin");
//DirectoryCatalog catalog = new DirectoryCatalog(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin"), "*.Data*.dll");
DirectoryCatalog catalog = new DirectoryCatalog(path, "*.dll");
_container = new CompositionContainer(catalog);
_container.ComposeParts();
}
private static void CheckContainer()
{
if (_container == null)
{
Initialize();
}
}
public static T GetInstance<T>()
{
CheckContainer();
return _container.GetExportedValue<T>();
}
Run Code Online (Sandbox Code Playgroud)
但autofac似乎让我感到困惑......我如何使用autofac将此功能添加到我的应用程序?
谢谢
我将该代码更改为:
private static ContainerBuilder _container;
private static IContainer container;
public static void Initialize()
{
_container = new ContainerBuilder(); …Run Code Online (Sandbox Code Playgroud) 我有一个 45-50 列和 45-50 行的数据表,我想创建一个校验和文本或 md5、sha1,我不知道哪个更好。如果还有其他文本,我将创建该文本并在数据库中搜索它。但是文本长度必须在 100-200 个字符之间,我不知道我是否可以做到。那么你对此有何看法,我该怎么做?
谢谢。
c# ×6
autofac ×2
.net ×1
asp.net ×1
carrierwave ×1
checksum ×1
datatable ×1
javascript ×1
list ×1
md5sum ×1
sqlite ×1
unit-of-work ×1
webpack ×1