我有一个由Entity Framework(EF)生成的员工类.
public partial class employee
{
private string name;
public string Name
{
get{return name;}
set{ name = value;}
}
}
Run Code Online (Sandbox Code Playgroud)
现在我想在name属性中放入一个必需的属性,用于在另一个员工的部分类中进行MVC3验证,这是由我编写的,以扩展由EF生成的那个,这样我就不必重写我的代码了.如果我刷新EF生成的模型.
我写的部分类在同一个程序集和名称空间中.
public partial class employee
{
// What should I write here to add required attribute in the Name property?
}
Run Code Online (Sandbox Code Playgroud) 我在MVC3中创建了局部视图.现在我想按下提交按钮发送文本框值作为表单提交的参数
我的部分观点是这样的
@using (Html.BeginForm("Searching", "AccountManager", FormMethod.Post, new { name ="Wat should i put here" }))
{
<input id="account" type="text" class="s" />
<input id="Search" type="submit" class="b" value="hi" />
}
Run Code Online (Sandbox Code Playgroud)
我的控制器就像
public viewResult Searching(string name)
{
// bussiness logic
return view();
}
Run Code Online (Sandbox Code Playgroud) 我试图从我的Android应用程序中的网站播放音频文件,但它遇到媒体播放器错误(1,-1004).
当我在Windows媒体播放器或vlc播放器中使用它时,流链接工作正常.为什么Android媒体播放器会产生此错误?我的代码是
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_play_file);
// Show the Up button in the action bar.
setupActionBar();
playSong("http://WEBSITE/001.mp3");
}
private void playSong(String songPath) {
MediaPlayer mP = new MediaPlayer();
try {
mP.setDataSource(songPath);
mP.setAudioStreamType(AudioManager.STREAM_MUSIC);
mP.prepare();
mP.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.start();
}
});
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalStateException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试在部分视图中为枚举模型呈现隐藏字段
我的代码是
@model App.PrivacyLevelEnum
@Html.HiddenFor(m=>m);
Run Code Online (Sandbox Code Playgroud)
我已经检查过模型不为空,但在渲染视图时出现以下错误
值不能为 null 或为空。\r\n参数名称: name 堆栈跟踪 在 System.Web.Mvc.Html.InputExtensions.InputHelper(HtmlHelper htmlHelper, InputType inputType, ModelMetadata 元数据, 字符串名称, 对象值, Boolean useViewData, Boolean isChecked, Boolean setId, Boolean isExplicitValue, String format, IDictionary`2 htmlAttributes) 在 System.Web.Mvc.Html.InputExtensions.HiddenHelper(HtmlHelper htmlHelper, ModelMetadata metadata, Object value, Boolean useViewData, String expression, IDictionary`2 htmlAttributes) 在 System.Web.Mvc.Html.InputExtensions.HiddenFor[TModel,TProperty](HtmlHelper`1 htmlHelper, Expression`1 表达式, IDictionary`2 htmlAttributes) 在 System.Web.Mvc.Html.InputExtensions.HiddenFor[TModel,TProperty](HtmlHelper`1 htmlHelper, Expression`1 表达式) 在 ASP._Page_Views_Profile_PrivacyLevel_cshtml.Execute() in c:\TFS\DEFAULTCOLLECTION\Gac.Hr\Development\Source\Gac.Hr.Web.Html5\Views\Profile\PrivacyLevel.cshtml:line 58 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy() 在 System.Web.Mvc.WebViewPage.ExecutePageHierarchy() 在 System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) 在 System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) …
我正在尝试使用 linq 来 nhibernate 3,我做了以下 linq 查询
var a = (from c in Session.Query<ChoiceValue>()
join Specific in
(
(from choicevaluelocale in Session.Query<ChoiceValueLocale>()
where
choicevaluelocale.UICulture == "en-GB"
select new
{
choicevaluelocale.ChoiceValue.ChoiceGroup.ChoiceGroupName,
choicevaluelocale.ChoiceValue.ChoiceValueId,
choicevaluelocale.DisplayName,
choicevaluelocale.Description
}))
on new { c.ChoiceGroup.ChoiceGroupName, c.ChoiceValueId }
equals new { Specific.ChoiceGroupName, ChoiceValueId = (Int32)Specific.ChoiceValueId } into Specific_join
from Specific in Specific_join.DefaultIfEmpty()
select new
{
c.ChoiceGroup.ChoiceGroupName,
ChoiceValueId = (Int32?)c.ChoiceValueId,
SpecificValueDisplayName = Specific.DisplayName,
SpecificValueDescription = Specific.Description,
}).ToList();
Run Code Online (Sandbox Code Playgroud)
但是在 c# 中的 n-hibernate 上执行它时,我遇到了以下错误
The method or operation is not implemented …Run Code Online (Sandbox Code Playgroud)