小编Bar*_*Alp的帖子

使用Nhibernate Criteria Api查询集合?

我有一个"Estate"实体,这个实体有一个集合"EstateFeatures"(类型:EstateFeature),而EstateFeature有一个属性"MyFeatureValue".

注意:这些是问题的有限属性.所有实体都有Id和所有necesarry等

房地产

IList<EstateFeature> EstateFeatures;
Run Code Online (Sandbox Code Playgroud)

EstateFeature

FeatureValue MyFeatureValue;
Run Code Online (Sandbox Code Playgroud)

FeatureValue

public virtual long Id;
Run Code Online (Sandbox Code Playgroud)

我正在尝试获得具有给定FeatureValue.Id的Real Estates

DetachedCriteria query = DetachedCriteria.For<Estate>();
Conjunction and = new Conjuction();
foreach (var id in idCollection)
   and.Add(Expression.Eq("MyFeatureValue.Id",id);

query
     .CreateCriteria("EstateFeatures")
     .Add(and);
IList<Estate> estates = query.GetExecutableCriteria(session).List<Estate>();
Run Code Online (Sandbox Code Playgroud)

这个查询没有返回任何内容,我做错了什么?

谢谢

.net c# nhibernate criteria icriteria

4
推荐指数
1
解决办法
1万
查看次数

具有MVC 2的自定义ViewModel强类型HTML帮助程序在Create上返回null对象?

我在尝试使用自定义视图建模创建表单创建实体时遇到了麻烦.下面是我的类别创建表单的自定义视图模型.

public class CategoryFormViewModel
{
    public CategoryFormViewModel(Category category, string actionTitle)
    {
        Category = category;
        ActionTitle = actionTitle;
    }

    public Category Category { get; private set; }
    public string ActionTitle { get; private set; }
}
Run Code Online (Sandbox Code Playgroud)

这是UI的用户控件

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<CategoryFormViewModel>" %>

        <h2>
            <span><%= Html.Encode(Model.ActionTitle) %></span>
        </h2>
        <%=Html.ValidationSummary() %>
        <% using (Html.BeginForm()) {%>
        <p>
            <span class="bold block">Ba?l?k:</span>
            <%=Html.TextBoxFor(model => Model.Category.Title, new { @class = "width80 txt-base" })%>
        </p>
        <p>
            <span class="bold block">S?ra Numaras?:</span>
            <%=Html.TextBoxFor(model => Model.Category.OrderNo, new { @class = "width10 …
Run Code Online (Sandbox Code Playgroud)

asp.net strongly-typed-view asp.net-mvc-2

4
推荐指数
1
解决办法
1655
查看次数

嵌套的jQuery循环?

我正在尝试使用jQuery循环插件构建幻灯片放映.

在幻灯片放映中有内容,内容内有基本图库.

图库使用的周期超时少于内容超时.所以内容等待15秒,图像库将有5个图片,3秒超时,然后15秒,然后内容更改.

一切听起来都不错但是当我执行页面时,它会循环内容和第一个图库.但当它跳转到第二个内容时,它不会循环图像库.

我试图$('#cycleImages').cycle({...将此代码块放在图库转发器上方,但它没有成功.

如何让这些嵌套循环一起工作?谢谢

<head runat="server">
<script type="text/javascript" src="/Js/jquery-1.2.6.js"></script>
<script src="/Js/jquery.cycle.all.min.js" type="text/javascript"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            $('#cycleContent').cycle({
                fx: 'scrollRight',
                delay: -1000,
                timeout: 15000
            });
        });
        $('#cycleImages').cycle({
            fx: 'fade',
            speed: 500,
            timeout: 3000,
            pause: 1
        });                  
    </script>
</head>
Run Code Online (Sandbox Code Playgroud)

这是我的html标记

<div id="cycleContent">
            <asp:Repeater ID="rptContent" runat="server">
                <ItemTemplate>
                    <div>
                        <h2 class="slideShow-type">("Type.Name") %></h2>
                        <h2 class="slideShow-title">("Title") %></h2>
                            <div id="cycleImages">
                                <asp:Repeater ID="rptBigPictures" DataSource='<%#Eval("Images") %>' EnableViewState="false"
                                    runat="server">
                                    <ItemTemplate>
                                        <asp:Image ID="imgProfile" runat="server" ImageUrl='<%#Eval("Path") + ".jpg" %>' />
                                    </ItemTemplate>
                                </asp:Repeater>
                            </div>
                    </div>
                </ItemTemplate>
            </asp:Repeater>
        </div>
Run Code Online (Sandbox Code Playgroud)

.net asp.net jquery cycle

1
推荐指数
1
解决办法
3238
查看次数

使用c#从id集合中获取4个(或任何计数)随机唯一ID的最简单方法是什么?

假设你有一个idCollection IList<long>并且你有一个方法来获得4个唯一的id.每次调用它时,它会为你提供随机的4个唯一ID?

var idCollec = new[] {1,2,3,4,5,6,7,8,9,10,11,12}.ToList();

For example {2,6,11,12}
            {3,4,7,8}
            {5,8,10,12}
            ...
            ..
Run Code Online (Sandbox Code Playgroud)

最聪明的方法是什么?

谢谢

c# asp.net generics c#-3.0

1
推荐指数
1
解决办法
323
查看次数


当我将其声明为参数时不起作用?

如果我将Bind属性声明为方法的参数,它就不会像预期的那样工作

[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Create([Bind(Exclude="ID")]int ServiceId, Event evnt)
        {
            var service = dbSrc.GetAll().WithID(ServiceId).SingleOrDefault();
            if (service == null)
Run Code Online (Sandbox Code Playgroud)

但如果我在课堂上声明它,它就可以了!

[Bind(Exclude = "ID")]
    partial class Event
    {
Run Code Online (Sandbox Code Playgroud)

触发create动作的表单在usercontrol中,我使用的是asp.net mvc 1?

我的数据库设置很好.id列是主键并自动生成.

可能是什么原因?或者它是版本1.0中的错误?

提前致谢

asp.net-mvc binding

1
推荐指数
1
解决办法
940
查看次数

我怎样才能获得等于string []的项目?

我有一个字符串数组

var controlsToGet = new[] {"lblHome","lblContact"};
Run Code Online (Sandbox Code Playgroud)

我有List<LanguageControl>,LanguageControl类包含控件.我想从列表中获取控件Control.Name == controlsToGet

我正在寻找类似的东西

var all = fooelements.where(l=>l.Control.Name == controlsToGet);
Run Code Online (Sandbox Code Playgroud)

有没有lambda或linq.

注意:我能够用Nhibernate的Disjunction做到这一点,我正在寻找类似的东西

编辑:如果我想将此查询用于实体框架的数据库,我该怎么办?

谢谢

c# linq lambda entity-framework

0
推荐指数
1
解决办法
181
查看次数