我正在为一个新项目草拟一些想法,并意识到我在设置MVC框架时遇到了一些困难(在这种情况下,CodeIgniter)我喜欢的方式.虽然我相信这可以通过更多地设计并找出更好的布局来克服,但它让我思考:MVC 不是最好的答案吗?如果没有,何时使用MVC对项目来说是一个好主意,何时不是?
我觉得MVC 可以用于任何网络应用程序,但我想知道什么时候它不是最好的解决方案.
我可以让我的EF对象只检索执行的sql中的特定列吗?如果我正在执行下面的代码来检索对象,那么我可以做些什么来获取某些列,如果需要的话?
public IEnumerable<T> GetBy(Expression<Func<T, bool>> exp)
{
return _ctx.CreateQuery<T>(typeof(T).Name).Where<T>(exp);
}
Run Code Online (Sandbox Code Playgroud)
这将生成包含所有列的select子句.但是,如果我有一个包含大量数据的列真的会降低查询速度,那么如何让我的对象从生成的sql中排除该列?
如果我的表有Id(int),Status(int),Data(blob),我该如何进行查询
select Id, Status from TableName
Run Code Online (Sandbox Code Playgroud)
代替
select Id, Status, Data from TableName
Run Code Online (Sandbox Code Playgroud)
根据下面的建议,我的方法是
public IEnumerable<T> GetBy(Expression<Func<T, bool>> exp, Expression<Func<T, T>> columns)
{
return Table.Where<T>(exp).Select<T, T>(columns);
}
Run Code Online (Sandbox Code Playgroud)
我这样称呼它
mgr.GetBy(f => f.Id < 10000, n => new {n.Id, n.Status});
Run Code Online (Sandbox Code Playgroud)
但是,我收到编译错误:
无法将类型'AnonymousType#1'隐式转换为'Entities.BatchRequest'
由于我是一名孤独的开发人员,我必须考虑我正在研究的系统的各个方面.最近我一直在考虑我的两个网站的性能,以及改进它的方法.像StackOverflow这样的网站宣称,"性能是一种功能".然而,"过早优化是所有邪恶的根源",我的客户都没有抱怨网站的表现.
我的问题是,表现总是很重要吗?性能应该始终是一个功能吗?
注:我不认为这个问题是一样的这一个,作为海报问什么时候要考虑性能,我问,如果这个问题的答案是永远的,如果是这样,为什么.我也不认为这个问题应该是CW,因为我相信这个答案有一个答案和推理.
我有两个程序集,A和B,其中A依赖于B.我试图将它们混合在一起,即以某种方式它不会破坏与babel混淆器的应用程序.
有没有办法做到这一点?显然,这个混淆器不能处理多个程序集.
如果这是一个问题,你会推荐哪个其他.NET混淆器 - 处理多个程序集?
我最近编写了一个脚本,该脚本解析了单个二进制字节月字段的文本表示.
(不要问: - {)
在摆弄sprintf一段时间之后,我放弃了并做了这件事;
our %months = qw / x01 1
x02 2
x03 3
x04 4
x05 5
x06 6
x07 7
x08 8
x09 9
x0a 10
x0b 11
x0c 12 /;
...
my $month = $months{$text};
Run Code Online (Sandbox Code Playgroud)
我侥幸逃脱,因为我只使用12个数字,但是有更好的方法吗?
我有一个程序正在为用户输出创建一个安全的目录.这工作正常,但我在其中创建的文件(或复制到它)最终只有管理员访问权限.
DirectoryInfo outputDirectory =
baseOutputDirectory.CreateSubdirectory(outputDirectoryName,
GetDirectorySecurity(searchHits.Request.UserId));
...
private DirectorySecurity GetDirectorySecurity(string owner)
{
const string LOG_SOURCE = "GetDirectorySecurity";
DirectorySecurity ds = new DirectorySecurity();
System.Security.Principal.NTAccount ownerAccount =
new System.Security.Principal.NTAccount(owner);
ds.SetOwner(ownerAccount);
ds.AddAccessRule(
new FileSystemAccessRule(owner,
FileSystemRights.FullControl,
AccessControlType.Allow));
//AdminUsers is a List<string> that contains a list from configuration
// That represents the admins who should be allowed
foreach (string adminUser in AdminUsers)
{
ds.AddAccessRule(
new FileSystemAccessRule(adminUser,
FileSystemRights.FullControl,
AccessControlType.Allow));
}
return ds;
}
/// <summary>
/// This method copies any static supporting files, such as javascripts …Run Code Online (Sandbox Code Playgroud) 我想在我的Spring XML上下文中定义一个bean,它具有类型List类型的属性:ie List<Class<?>> classes
我如何向bean发送一些类,比如java.lang.String和java.lang.Integer?
该列表不需要是可重用的,即我不会在另一个bean中引用它.
我在使用.NET中的Random类时遇到问题,我正在实现一个工作正常的线程集合,除了一个较小的细节.该集合是一个Skip列表,熟悉它的人知道,对于插入的每个节点,我需要生成一个新的高度,这是<= CurrentMaxHeight+1我用来做这个的代码(我知道这是非常低效的,但它的工作原理)这是我现在的主要优先事项)
int randomLevel()
{
int height = 1;
while(rnd.NextDouble() >= 0.5 && height < MaxHeight)
++height;
return height;
}
Run Code Online (Sandbox Code Playgroud)
我的问题在于,有时候我连续几千个元素只能从这里获得一次,这会杀死跳过列表的性能.10.000个元素连续生成这个方法只有1个的机会,看起来非常渺茫(非常一致).
所以我假设(猜测)Random对象在某种程度上存在问题,但我真的不知道从哪里开始挖掘.所以我转向stackoverflow看看是否有人有想法?
编辑
rnd-variable在类中声明SkipList<T>,并且可以从多个线程访问(每个线程调用集合上的.Add和Add调用.randomLevel)
.net ×2
c# ×2
php ×2
asp.net ×1
babel ×1
collections ×1
hex ×1
java ×1
obfuscation ×1
optimization ×1
performance ×1
perl ×1
permissions ×1
security ×1
spring ×1