我正在使用引导程序框架并尝试将图像水平居中而不成功.
我已经尝试了各种技术,例如将12个网格系统分成3个相等的块,例如
<div class="container">
<div class="row">
<div class="span4"></div>
<div class="span4"><img src="logo.png" /></div>
<div class="span4"></div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
使图像相对于页面居中的最简单方法是什么?
微软刚刚宣布计算日期(超过闰年)的软件错误导致上周Windows Azure出现重大中断.
DateTime.Now.AddYears(1)闰年的判断是否真的是一个简单的错误?
什么编码实践可以防止这种情况?
编辑
正如dcstraw DateTime.Now.AddYears(1)在闰年指出的确实在.NET中返回正确的日期.所以它不是框架错误,但显然是日期计算中的错误.
我正在寻找一种超级简单的方法来创建一个双列格式来显示网页上的一些数据.我怎样才能达到以下格式:
<table>
<tr>
<td>AAA</td>
<td>BBB</td>
</tr>
</table>
Run Code Online (Sandbox Code Playgroud)
我也对HTML5/CSS3技术持开放态度.
我正在使用StructureMap来解析对我的存储库类的引用.我的存储库接口实现了IDisposable,例如
public interface IMyRepository : IDisposable
{
SomeClass GetById(int id);
}
Run Code Online (Sandbox Code Playgroud)
使用Entity Framework实现接口:
public MyRepository : IMyRepository
{
private MyDbContext _dbContext;
public MyDbContext()
{
_dbContext = new MyDbContext();
}
public SomeClass GetById(int id)
{
var query = from x in _dbContext
where x.Id = id
select x;
return x.FirstOrDefault();
}
public void Dispose()
{
_dbContext.Dispose();
}
}
Run Code Online (Sandbox Code Playgroud)
无论如何提到我正在使用StructureMap来解析IMyRepository.那么何时,何地以及如何调用我的处理方法?
我试图首先在EF代码中建立多对多关系,但默认约定是错误的.以下类描述了这种关系:
class Product
{
public int Id { get; set; }
public string Name { get; set; }
}
class Account
{
public int Id { get; set; }
public string Name { get; set; }
public virtual ICollection<Product> Products { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
一个帐户可以有许多产品.
但是,EF约定将创建DB表,如下所示:
Products Table
--------------
Id
Name
Account_Id <- What is this?
Accounts Table
--------------
Id
Name
Run Code Online (Sandbox Code Playgroud)
这看起来不像是一个多对多的表结构?如何配置流畅的API以反映关系并创建中间表:
AccountProducts Table
---------------------
Account_Id
Product_Id
Run Code Online (Sandbox Code Playgroud) 是否存在处理大文件的最佳块大小?我有一个上传服务(WCF),用于接受几百兆字节的文件上传.
我已经尝试了4KB,8KB到1MB的块大小.较大的块大小有利于提高性能(更快的处理速度),但却以内存为代价.
那么,有没有办法在上传文件时计算出最佳的块大小.如何进行这样的计算呢?它是可用内存和客户端,CPU和网络带宽的组合,它决定了最佳尺寸吗?
干杯
编辑:可能应该提到客户端应用程序将处于silverlight状态.
我试图找出哪个层应该负责域驱动设计项目中的缓存(插入/删除)工作.目标是通过缓存从存储库中检索的任何实体来提高Web应用程序的性能.
我的解决方案分为以下几种:
MyApp.Infrastracture
MyApp.Repositories
MyApp.Domain
MyApp.WebApplication
Run Code Online (Sandbox Code Playgroud)
我觉得因为它只是利用缓存的Web应用程序,那么缓存逻辑应该应该是这个层吗?然而,这并不正确,因为我希望保持Web应用程序的轻量级并专注于提供网页.
此外,缓存不是一流的域概念,因此在Domain层中不具有自然的适应性.
该怎么办?
继我之前提出的问题之后,我现在正试图弄清楚如何为AND&OR查询构建动态表达式.
给定以下字符串数组:
string[] ranges = new string[]{"0-100", "100-200", "500-1000"};
Run Code Online (Sandbox Code Playgroud)
我想在linq表达式中动态表达这一点 - 有点像:
var v = from p in products
where
(p.Amount >= 0 && p.Amount <= 100) ||
(p.Amount >= 101 && p.Amount <= 200) ||
(p.Amount >= 500 && p.Amount <= 1000)
select p;
Run Code Online (Sandbox Code Playgroud)
如何在此循环中动态构建linq表达式?
string[] ranges = new string[]{"0-100", "100-200", "500-1000"};
var query = products.AsQueryable();
foreach (var item in ranges)
{
int min = int.Parse(item.Split('-').First());
int max = int.Parse(item.Split('-').Last());
//Linq expression?
}
Run Code Online (Sandbox Code Playgroud) 我正在将Unity配置移动到web.config文件.我坚持如何将以下代码配置迁移到xml格式:
var container = new UnityContainer();
container.RegisterType<IPrincipal>(new InjectionFactory(x=> HttpContext.Current.User));
return container;
Run Code Online (Sandbox Code Playgroud)
以下是XML声明:
<unity xmlns="http://schemas.microsoft.com/practices/2010/unity">
<alias alias="IRepository" type="Model.IRepository, Model" />
<alias alias="Repository" type="Data.Repository, Data" />
<container>
<register type="IRepository" mapTo="Repository" />
</container>
</unity>
Run Code Online (Sandbox Code Playgroud) .net c# inversion-of-control unity-container service-locator
我已经设置了我的通用存储库,如下所示:
public interface IRepository<T> : IDisposable where T : Entity
{
T GetById(int id);
}
public abstract class Repository<T> : IRepository<T> where T : Entity
{
protected readonly SqlDbContext _context = new SqlDbContext();
public T GetById(int id)
{
return _context.Set<T>().Find(id);
}
}
Run Code Online (Sandbox Code Playgroud)
为了在我的MVC应用程序中启用依赖项注入,我还创建了一个Product接口,因为签名不同.其他存储库也是如此.
public interface IProductRepository : IRepository<Product>
{
IEnumerable<Product> GetDiscountedProducts();
}
Run Code Online (Sandbox Code Playgroud)
和实现(注意继承)
public class ProductRepository : Repository<Product>, IProductRepository
{
public IEnumerable<Product> GetDiscountedProducts()
{
return _context.Set<Product>().Where(x=>x)...
}
}
Run Code Online (Sandbox Code Playgroud)
最后,使用unity将存储库注入MVC控制器
public HomeController(IProductRepository repository)
{
}
Run Code Online (Sandbox Code Playgroud)
这只是我还是这个继承链在这里有点乱?有没有办法改进这个设计?
c# ×7
css ×2
.net ×1
asp.net ×1
asp.net-mvc ×1
associations ×1
chunking ×1
datetime ×1
dispose ×1
html ×1
html5 ×1
linq ×1
silverlight ×1
structuremap ×1
wcf ×1