当我在Visual Studio中的解决方案中构建项目时(它可以是C#VB.NET F#或者其他)我想每个项目只生成一个程序集吗?
所以,如果我有一个包含项目1 2 3和4的解决方案当我逐个构建每个项目时,我得到了4个组件吗?
但是,是否有可能让构建器/编译器只为整个解决方案生成一个程序集?或者两个项目一起编译?
我的意思是使用命令行调用编译器并设置目标程序集......
我需要找到每个作者的最新帖子,然后对结果进行分组,这样我每个作者只会发一个最新的帖子.
SELECT wp_posts.* FROM wp_posts
WHERE wp_posts.post_status='publish'
AND wp_posts.post_type='post'
GROUP BY wp_posts.post_author
ORDER BY wp_posts.post_date DESC
Run Code Online (Sandbox Code Playgroud)
这是正确地对输出进行分组,因此我每个作者只获得一个帖子,但是在分组后将结果排序,而不是在选择之前.
我正在使用Entity Framework 4构建一个ASP.Net MVC 3应用程序.当执行下面两段代码时,两个变量(query1和query2)的返回类型都是
System.Data.Objects.ObjectQuery<Asset.Model.Equipment>
Run Code Online (Sandbox Code Playgroud)
Query1使用ObjectContext的直接实例,但是,Query2使用存储库模式,即它在EquipmentService中调用GetEquipment,后者又在Equipment Repository中调用相同的命名方法.Service和Repository中的两个方法都返回
IQueryable<Equipment>
Run Code Online (Sandbox Code Playgroud)
如何,这是我的问题,为什么query2只有在我包含时才会起作用
using System.Linq.Dynamic;
Run Code Online (Sandbox Code Playgroud)
在我的控制器的顶部
using (AssetEntities context = new AssetEntities())
{
var query1 = context.Equipments
.OrderBy("it." + sidx + " " + sord)
.Skip(pageIndex * pageSize)
.Take(pageSize);
}
var query2 = equipService.GetEquipment()
.OrderBy(sidx + " " + sord)
.Skip(pageIndex * pageSize)
.Take(pageSize);
Run Code Online (Sandbox Code Playgroud)
如果我从我的控制器omitt System.Linq.Dynamic,我在Query2中得到一个错误
.OrderBy(sidx + " " + sord)
Run Code Online (Sandbox Code Playgroud)
哪个州
The type arguments for method 'System.Linq.Queryable.OrderBy<TSource,TKey>(System.Linq.IQueryable<TSource>, System.Linq.Expressions.Expression<System.Func<TSource,TKey>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly
Run Code Online (Sandbox Code Playgroud)
有谁知道为什么query1可以工作而不必使用System.Linq.Dynamic,但是query2需要它来执行? …
linq-to-entities jqgrid dynamic-linq entity-framework-4 asp.net-mvc-3
我在几个嵌入式平台的编译器上工作.用户最近抱怨我们的一个编译器出现以下行为.给出这样的代码:
extern volatile int MY_REGISTER;
void Test(void)
{
(void) (MY_REGISTER = 1);
}
Run Code Online (Sandbox Code Playgroud)
编译器生成它(在伪汇编程序中):
Test:
move regA, 1
store regA, MY_REGISTER
load regB, MY_REGISER
Run Code Online (Sandbox Code Playgroud)
也就是说,它不仅写入MY_REGISTER,而且之后将其读回.由于性能原因,额外负载使他心烦意乱.我解释说这是因为根据标准"赋值表达式在赋值后具有左操作数的值,[...]".
奇怪的是,删除cast-to-void会改变行为:负载消失.用户很高兴,但我只是感到困惑.
所以我也在几个版本的GCC(3.3和4.4)中检查了这一点.在那里,编译器永远不会生成负载,即使明确使用该值,例如
int TestTwo(void)
{
return (MY_REGISTER = 1);
}
Run Code Online (Sandbox Code Playgroud)
变成
TestTwo:
move regA, 1
store regA, MY_REGISTER
move returnValue, 1
return
Run Code Online (Sandbox Code Playgroud)
有没有人对该标准的正确解释有何看法?回读是否应该发生?如果使用该值或将其转换为void,则添加只读是正确还是有用?
嘿,我写了一个继承了一些功能的类(A),包括导航按钮的实现.A类同时具有查看和编辑模式,我只想在编辑模式下显示按钮.到目前为止,我无法删除此按钮,我真的不想创建另一个类只是为了编辑.
其他类也继承了这个功能,所以我真的不想弄乱父母.
我用来创建按钮的代码如下:
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *buttonImage = [UIImage imageNamed:@"button.png"];
[button addTarget:self
action:@selector(buttonPressed:)
forControlEvents:UIControlEventTouchUpInside];
button.bounds = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
[button setTitle:NSLocalizedString(@"BUTTON", @"")
forState:UIControlStateNormal];
LPRBSLabel *buttonLabel = [[LPRBSLabel alloc] initWithStyle:UICustomeButtonTitle];
[button setTitleEdgeInsets:UIEdgeInsetsMake(0.0, 0.0, -5.0, 0.0)];
button.titleLabel.font = buttonLabel.font;
[button setTitleColor:buttonLabel.textColor forState:UIControlStateNormal];
[buttonLabel release];
UIBarButtonItem *barLeftInfoButton = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = barLeftInfoButton;
[barLeftInfoButton release];
Run Code Online (Sandbox Code Playgroud) 我知道你可以通过使用闭包和立即调用函数在JavaScript中实现"私有性".
但是,如果我需要全功能原型设计呢?我根本不知道在对象的原型中有私有成员.如果我使用特权方法,我可以拥有私有变量和公共方法,但我失去了原型设计的选项.
Douglas Crockford"禁止"使用悬空(在标识符前加上下划线表示它不是公共接口的一部分).
但使用它是不是很糟糕?因为没有办法让它真正私密.
你对此有何看法?你怎么处理它?
我对这段代码有些问题.注意评论.为什么?
struct node
{
struct node *left;
struct node *right;
int value;
};
static struct node root2;
int main()
{
struct node *root = (struct node *) malloc(sizeof(struct node));
assert(root->left == NULL); /* not failed. Why? */
assert(root->right == NULL); /* not failed. Why? */
assert(root2.left == NULL); /* not failed. Why? */
assert(root2.right == NULL); /* not failed. Why? */
struct node root1;
assert(root1.left == NULL); /* this failed. Why? */
assert(root1.right == NULL); /* this failed. Why? */ …Run Code Online (Sandbox Code Playgroud) 如何在不保存的情况下将内存中的图像放入浏览器.
例如:
function getImage()
{
$imageFile = imagecreatefromjpeg('Map.jpg');
$imageObject = imagecreatefrompng('image2.png');
imagealphablending($imageFile, true);
imagecopy(....);
$ret = array($imageFile, $imageObject) ;
return $ret
}
<?php $ret = getImage(); ?>
<img src = <?php $ret[0];? alt=''>
Run Code Online (Sandbox Code Playgroud)
这可能,没有保存?
我有以下代码.sprintf中第二个%d的输出始终显示为零.我想我指的是错误的说明符.任何人都可以帮助我获得具有正确值的写字符串.这必须以posix标准实现.感谢您的投入
void main() {
unsigned _int64 dbFileSize = 99;
unsigned _int64 fileSize = 100;
char buf[128];
memset(buf, 0x00, 128);
sprintf(buf, "\nOD DB File Size = %d bytes \t XML file size = %d bytes", fileSize, dbFileSize);
printf("The string is %s ", buf);
}
Run Code Online (Sandbox Code Playgroud)
输出:
The string is
OD DB File Size = 100 bytes XML file size = 0 bytes
Run Code Online (Sandbox Code Playgroud) 以下声明在C++文件中添加了几个用于编译的运算符.该定义包含在C和C++文件中.
PC-Lint报告错误114:标签'Rect'的结构声明不一致但我确信它是安全的.
我正在使用Visual Studio 2008进行编译.
编辑 - 添加我发送给我的客户的说明
关于Rect问题; 如何知道结构在C和C++中的大小相同,消除了对"未定义行为"的怀疑.
如果数据结构中字段的实际位置根据编译而变化,则会发生未定义的行为.
您必须将所有成员变量访问视为最终解析为指针,由指向对象存储开头的指针计算,并根据该结构中的内容计算偏移量.
打包和数据对齐设置会影响偏移的值.
允许编译器重新排序类型以获得最佳访问权限 - 这是一种未定义的行为,假设只是因为您按给定顺序声明了两个成员实际存储的顺序.声明命令唯一保证的是初始化,复制和销毁顺序.
但是,当您在同一编译器中讨论给定结构的C和C++编译时,使用相同的偏移设置,实际重新排序的可能性实际上为零.
因此,我们唯一需要担心的是字段偏移的任何差异.
对于包含简单4个短整数的结构,只需确认C版本和C++版本的大小相同,即可确保它们的偏移量完全相同.为了更加小心,我们还可以检查结构尺寸= 4*sizeof(短).
我认为值得添加这些检查但是一旦完成,就没有必要重构代码,因为在C和C++中使用单独的类型(或者将正在使用的函数移动到自由函数中)是必需的.
/**
Mac-compatible rectangle type with some operators added for C++ use.
@ingroup QuickdrawPort
*/
struct Rect {
short top;
short left;
short bottom;
short right;
#ifdef __cplusplus
Rect(short _top=0, short _left=0, short _bottom=0, short _right=0) :
top(_top),
left(_left),
bottom(_bottom),
right(_right)
{}
#ifdef _WINNT_ // WinDef.h has been included
const Rect& operator=(const tagRECT& rhs) {
top = short(rhs.top); …Run Code Online (Sandbox Code Playgroud) c ×3
c++ ×2
inheritance ×2
.net ×1
assemblies ×1
c99 ×1
closures ×1
dynamic-linq ×1
group-by ×1
image ×1
ios ×1
javascript ×1
jqgrid ×1
lint ×1
long-long ×1
mysql ×1
php ×1
prototype ×1
save ×1
sql-order-by ×1
uibutton ×1
uint64 ×1
volatile ×1
wordpress ×1