public class Company
{
public int id { get; set; }
public int Name { get; set; }
}
List<Company> listofCompany = new List<Company>();
Run Code Online (Sandbox Code Playgroud)
这是我的公司列表集合,我想使用LINQ为Name属性赋值
listofCompany.Where(d => d.Id = 1);
Run Code Online (Sandbox Code Playgroud)
(我想要公司ID 1的名称属性)
我该如何分配它.
我在Entity Framework Code First上使用Generic Repository模式.一切都工作正常,直到我需要在查询中包含更多实体.我成功地包含了一个实体,但现在我无法弄清楚如何包含多个实体.看看到目前为止我得到了什么:
public IQueryable<TEntity> GetQuery<TEntity>() where TEntity : class
{
var entityName = GetEntityName<TEntity>();
return _objectContext.CreateQuery<TEntity>(entityName);
}
public IList<TEntity> GetQueryWithInclude<TEntity>(string toInclude) where TEntity : class
{
var entityName = GetEntityName<TEntity>();
return _objectContext.CreateQuery<TEntity>(entityName).Include(toInclude).ToList();
}
private string GetEntityName<TEntity>() where TEntity : class
{
return string.Format("{0}.{1}", _objectContext.DefaultContainerName, _pluralizer.Pluralize(typeof(TEntity).Name));
}
Run Code Online (Sandbox Code Playgroud)
我尝试但没有工作的是将一个字符串数组传递给一个函数,然后尝试在查询之上"追加"包含.我在想,如果我叫GetQueryWithInclude并在同一时间聚集查询的结果通过了实体名称(实际导航性能),但我担心这可能会重复在每次调用查询的结果...您认为最好的方法是什么?
提前致谢!
更新:
这是我想要实现的一个例子:
public IQueryable GetQueryWithIncludes(string[] otherEntities)
{
var entityName = GetEntityName<TEntity>();
//now loop over the otherEntities array
//and append Include extensions to the query
//so inside the loop, something …Run Code Online (Sandbox Code Playgroud) c# entity-framework repository-pattern entity-framework-4 ef-code-first
我有运行Centos的VPS.我在VPS上设置了subversion.在Xcode中进行设置时,Xcode会报告一切正常.但是,当我导入项目时,Xcode会发出警告:
Authentication realm: <svn://**********.net:3690> **********-**********
Password for 'svn':
Authentication realm: <svn://**********.net:3690> **********-**********
Username: svn: Can't read stdin: End of file found
Run Code Online (Sandbox Code Playgroud)
我甚至无法创建目录,但Xcode报告它可以很好地连接到它.我已输入正确的用户名和密码.
我能够在Visual Studio中使用第三方插件在同一地址工作,所以我知道服务器不是给出了问题.我使用visual studio上传了一些文件.
有没有人在他们的xcode 4中工作颠覆?
我在尝试连接到mysql时遇到了很大的问题.当我跑:
/usr/local/mysql/bin/mysql start
Run Code Online (Sandbox Code Playgroud)
我有以下错误:
Can't connect to local MySQL server through socket '/var/mysql/mysql.sock' (38)
Run Code Online (Sandbox Code Playgroud)
我确实mysql.sock在/var/mysql目录下.
在/etc/my.cnf我有:
[client]
port=3306
socket=/var/mysql/mysql.sock
[mysqld]
port=3306
socket=/var/mysql/mysql.sock
key_buffer_size=16M
max_allowed_packet=8M
Run Code Online (Sandbox Code Playgroud)
在/etc/php.ini我有:
; Default socket name for local MySQL connects. If empty, uses the built-in
; MySQL defaults.
mysql.default_socket = /var/mysql/mysql.sock
Run Code Online (Sandbox Code Playgroud)
我已经重启了apache sudo /opt/local/apache2/bin/apachectl restart
但我仍然有错误.
否则,我不知道这是否相关,但是当mysql_config --sockets我得到时
--socket [/tmp/mysql.sock]
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用通配符来获取id以"jander"开头的所有元素的id.我试过了$('#jander*'),$('#jander%')但它不起作用..
我知道我可以使用元素类来解决它,但也可以使用通配符?
<script type="text/javascript">
var prueba = [];
$('#jander').each(function () {
prueba.push($(this).attr('id'));
});
alert(prueba);
});
</script>
<div id="jander1"></div>
<div id="jander2"></div>
Run Code Online (Sandbox Code Playgroud) 我是iPhone-Development的新手.
我想在点击UIButton时播放声音.我尝试了以下方法:
ViewController.h:
@interface JahrenzeitenViewController : UIViewController <AVAudioPlayerDelegate> {
UIButton *button_PlaySound;
AVAudioPlayer *audioPlayer;
}
@property (nonatomic, retain) IBOutlet UIButton *button_PlaySound;
Run Code Online (Sandbox Code Playgroud)
ViewController.m
- (IBAction)playSound {
//[audioPlayer release];
//audioPlayer = nil;
NSString *audioFilePath = [[NSBundle mainBundle] pathForResource:@"test" ofType:@"wav"];
NSURL *audioFileURL = [NSURL fileURLWithPath:audioFilePath];
NSError *error = nil;
audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:audioFileURL error:&error];
[audioPlayer setDelegate:self];
[audioPlayer prepareToPlay];
[audioPlayer play];
if (audioPlayer == nil)
NSLog(@"Error playing sound. %@", [error description]);
else
[audioPlayer play];
Run Code Online (Sandbox Code Playgroud)
如果我尝试运行应用程序,我会收到以下错误:
没有找到符号(S)为i386硬件架构collect2:为i386硬件架构未定义的符号: "_OBJC_CLASS _ $ _ AVAudioPlayer",从引用:objc级,裁判在JahrenzeitenViewController.o LD LD返回1个退出状态
我也试过换线 …
我想了解Cocos2d,我已经阅读了更多关于Cocos2D的3个教程,但我还没有任何明确的想法,如何在MAC上安装Cocos2D.如果有人知道Coco2D的正确安装步骤,请告诉我,以便我可以从Cocos2D开始.
我有一个标签<a href="#"> Previous </a> 1 2 3 4 <a href="#"> Next </a>,在某些情况下我希望这个标签被完全禁用.
来自评论的代码(这是链接的生成方式)
if (n_index != n_pages)
a = a+'<li><a href="#" onclick="javascript:paginateAjaxPage('+(n_index+1) +','+stype+');">></a></li><li><a href="#" onclick="javascript:paginateAjaxPage('+n_pages+','+stype+');" >>></a></li>';
else
a = a+'<li><a style="cursor: pointer;" onclick="return false;">></a></li><li><a style="cursor: pointer;" onclick="return false" >>></a></li>';
a = a+'</ul></div>';
Run Code Online (Sandbox Code Playgroud) 我现在正在使用phpbb 3.0.8.它拥有3,000名用户和约60,000个帖子.我正在将论坛改为另一个,用经典的ASP编写(我知道人们会对此不赞成,但我有充分的理由).
我的网站是用ASP.net编写的.经典的ASP论坛有一个连接它的API.我把所有这些都设置好了,它运行正常.我已经写了自己的登录表单.
我想要复制所有用户帐户.目前的论坛有表:
Username | Password | Hash | Salt
Run Code Online (Sandbox Code Playgroud)
我已经覆盖了经典的ASP哈希技术,现在使用ASP.net Security.SHA1哈希.密码存储为SHA1(rawpassword + salt).
我的计划是将新字段存储在当前的字段旁边:
UserID | Password | Hash | Salt | PHPBBHash
Run Code Online (Sandbox Code Playgroud)
当用户登录时,如果设置了PHPBB hashh字段,则使用PHPBB哈希散列密码.然后,如果登录成功,它将删除PHPBBHash字段,并创建当前系统哈希值.这样,这是从PHPBB到新论坛的平稳过渡,没有人丢失他们的帐户.
我的问题是,给定PHPBB哈希,用户名和密码,在ASP.net中c#如何验证PHPBB哈希?它是如何计算的?
我担心的是经典的ASP哈希函数声称是SHA1,但它产生了不同的结果Securiy.SHA1.
如果有人能给我一个明确的解决方案,我会对此表示赏心悦目,我很欣赏链接到资源的答案,但我仍然在努力理解它.
原始密码:
blingblangblaow222
Run Code Online (Sandbox Code Playgroud)
在PHPBB3数据库中:
username: Tom
username_clean: tom
user_password: $H$9ojo08A3LuhnkXR27p.WK7dJmOdazh0
user_passchg: 1301433947
user_form_salt: 637f480dfdab84ef
Run Code Online (Sandbox Code Playgroud)
使用来自Vishalgiris的示例代码回答,我们这样做:
phpBB.phpBBCryptoServiceProvider cPhpBB = new phpBB.phpBBCryptoServiceProvider();
string remoteHash = "$H$9ojo08A3LuhnkXR27p.WK7dJmOdazh0";
bool result = cPhpBB.phpbbCheckHash("blingblangblaow222", remoteHash);
Response.Write("<BR><BR><BR>" + result);
Run Code Online (Sandbox Code Playgroud)
这实际上返回true.超!但有谁知道为什么这有效?我很困惑,它似乎根本不考虑盐.
我在我的应用程序中,我有控制后退按钮,但我也想控制主页按钮.我写了代码,但我无法控制HOME按钮.这是我的代码.帮助我实现它.
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK )
{
return false;
}
else if (keyCode == KeyEvent.KEYCODE_HOME)
{
return false;
}
return super.onKeyDown(keyCode, event);
}
Run Code Online (Sandbox Code Playgroud)