Web Images Videos Maps News Shopping Gmail more »
Recently Visited Groups | Help | Sign in
Google Groups Home
NBear使用时遇到参数是数组时的问题
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  16 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
寻路者  
View profile  
 More options Dec 5 2006, 7:01 am
From: "寻路者" <181443...@qq.com>
Date: Tue, 05 Dec 2006 04:01:43 -0800
Local: Tues, Dec 5 2006 7:01 am
Subject: NBear使用时遇到参数是数组时的问题
public interface T_Sell:Entity
    {
        [PrimaryKey]
        Guid ID
        {
            get;
            set;
        }

        string Fac_Code
        {
            get;
            set;
        }

        string City_ID
        {
            get;
            set;
        }

        [NotNull]
        DateTime Log_Time
        {
            get;
            set;
        }

        [FkReverseQuery(LazyLoad=true)]
        T_Factory Factory
        {
            get;
            set;
        }

        [FkReverseQuery(LazyLoad = true)]
        T_Area_City AreaCity
        {
            get;
            set;
        }
该表有2个外键,分别是City_ID(0对应表
T_Area_City),Fac_Code(对应表T_Factory)
现在要求查询:一个厂家在某一城市或某几个城市的销售记录.
储存过程SQL语句:select *  from T_Sell
where(fac_code=0 and (city_ID=01 or city_ID=02))
这样City_ID就变成一个数组参数,这样的话要怎么用GateWay解决?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile  
(1 user)  More options Dec 5 2006, 7:17 am
From: Teddy <shijie...@gmail.com>
Date: Tue, 5 Dec 2006 20:17:22 +0800
Local: Tues, Dec 5 2006 7:17 am
Subject: Re: NBear使用时遇到参数是数组时的问题

可以在使用 Gateway.FindArray<T_Sell>(TSell._.Fac_Code == "0" & (TSell._.City_ID
== 1 | TSell._..City_ID == 2) ) 这样的语法来查询。

Teddy

On 12/5/06, 寻路者 <181443...@qq.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 5 2006, 7:26 am
From: "寻路者" <181443...@qq.com>
Date: Tue, 05 Dec 2006 04:26:14 -0800
Local: Tues, Dec 5 2006 7:26 am
Subject: Re: NBear使用时遇到参数是数组时的问题
我是这样写的
T_Sell[] GetSaleDataByCity(string fac_Code, string[] City_ID)
        {
            int i;
            for (i = 0; i < City_ID.Length;i++)
            {
                return Gateway.Default.FindArray<T_Sell>((fac_Code ==
T_Sell._.Fac_Code) & (City_ID[i] == T_Sell._.City_ID),
OrderByClip.Default);
            }
        }
编译的时候没法通过是什么原因?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Dec 5 2006, 7:42 am
From: Teddy <shijie...@gmail.com>
Date: Tue, 5 Dec 2006 20:42:07 +0800
Local: Tues, Dec 5 2006 7:42 am
Subject: Re: NBear使用时遇到参数是数组时的问题

你的代码让人看不懂,循环里面一个return,第一次执行return就会退出循环和整个函数,你要的逻辑完全达不到,思路混乱!!

On 12/5/06, 寻路者 <181443...@qq.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 5 2006, 8:36 pm
From: "寻路者" <181443...@qq.com>
Date: Tue, 05 Dec 2006 17:36:01 -0800
Local: Tues, Dec 5 2006 8:36 pm
Subject: Re: NBear使用时遇到参数是数组时的问题
我现在要实现上面的方法,要怎样来传递City_ID的值呢?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jason Ye  
View profile   Translate to Translated (View Original)
 More options Dec 5 2006, 8:46 pm
From: "Jason Ye" <ycch...@gmail.com>
Date: Wed, 06 Dec 2006 01:46:39 -0000
Local: Tues, Dec 5 2006 8:46 pm
Subject: Re: NBear使用时遇到参数是数组时的问题
new 一个
WhereClip,再循环构造这个whereclip,最后传到FindArray方法中。

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile  
 More options Dec 5 2006, 8:48 pm
From: Teddy <shijie...@gmail.com>
Date: Wed, 6 Dec 2006 09:48:04 +0800
Local: Tues, Dec 5 2006 8:48 pm
Subject: Re: NBear使用时遇到参数是数组时的问题

       T_Sell[] GetSaleDataByCity(string fac_Code, string[] City_ID)
       {
           WhereClip whereFacCode = fac_Code == T_Sell._.Fac_Code;
           WhereClip whereCities = null;
           if (City_ID != null)
           {
               if (City_ID > 0)
               {
                   whereCities = City_ID[0] == T_Sell._.City_ID;
                   for (int i = 1; i < City_ID.Length; i++)
                   {                        whereCities = whereCities |
City_ID[i] == T_Sell._.City_ID;
                   }
               }
           }
           WhereClip where = (whereCities == null ? whereFacCode :
whereFacCode & whereCities);
           return Gateway.Default.FindArray<T_Sell>(where,
OrderByClip.Default);
       }

On 12/6/06, 寻路者 <181443...@qq.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 5 2006, 9:24 pm
From: "寻路者" <181443...@qq.com>
Date: Tue, 05 Dec 2006 18:24:25 -0800
Local: Tues, Dec 5 2006 9:24 pm
Subject: Re: NBear使用时遇到参数是数组时的问题
十分感谢你的回复!!

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
寻路者  
View profile   Translate to Translated (View Original)
 More options Dec 11 2006, 4:32 am
From: "寻路者" <181443...@qq.com>
Date: Mon, 11 Dec 2006 01:32:17 -0800
Local: Mon, Dec 11 2006 4:32 am
Subject: Re: NBear使用时遇到参数是数组时的问题
今天在运行这段代码的时候当City的数目超过400时,会出现嵌套太多的错误提示.
如果利用SQL语句进行查询,如何把结果传递给实体?

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Dec 11 2006, 4:43 am
From: Teddy <shijie...@gmail.com>
Date: Mon, 11 Dec 2006 17:43:57 +0800
Local: Mon, Dec 11 2006 4:43 am
Subject: Re: NBear使用时遇到参数是数组时的问题

你可以试试最新的v3.4.0版中的In方法。
下载地址:http://www.codeplex.com/nbear/Release/ProjectReleases.aspx

       T_Sell[] GetSaleDataByCity(string fac_Code, string[] City_ID)
       {
           return Gateway.Default.FindArray<T_Sell>(fac_Code ==
T_Sell._.Fac_Code & T_Sell._.City_ID.In(City_ID), OrderByClip.Default);
       }

这样就行了,是不是简单很多呢?

Teddy

On 12/11/06, 寻路者 <181443...@qq.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
寻路者  
View profile   Translate to Translated (View Original)
 More options Jan 29 2007, 1:07 am
From: "寻路者" <181443...@qq.com>
Date: Sun, 28 Jan 2007 22:07:10 -0800
Local: Mon, Jan 29 2007 1:07 am
Subject: Re: NBear使用时遇到参数是数组时的问题
今天在整理代码时,怎么没有找到你提供的IN方法,只有LIKE方法.

On 2006年12月11日, 下午5时43分, Teddy <shijie...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Jan 29 2007, 1:13 am
From: Teddy <shijie...@gmail.com>
Date: Mon, 29 Jan 2007 14:13:55 +0800
Local: Mon, Jan 29 2007 1:13 am
Subject: Re: NBear使用时遇到参数是数组时的问题

这个InSubQuery方法比较特别,定义在Gateway里的,是一个Gateway的方法,返回一个WhereClip。

Teddy

On 1/29/07, 寻路者 <181443...@qq.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
寻路者  
View profile   Translate to Translated (View Original)
 More options Jan 29 2007, 1:26 am
From: "寻路者" <181443...@qq.com>
Date: Sun, 28 Jan 2007 22:26:56 -0800
Local: Mon, Jan 29 2007 1:26 am
Subject: Re: NBear使用时遇到参数是数组时的问题
我怎么找不到这个方法?版本也更新的最新.
On 1月29日, 下午2时13分, Teddy <shijie...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Jan 29 2007, 1:54 am
From: Teddy <shijie...@gmail.com>
Date: Mon, 29 Jan 2007 14:54:37 +0800
Local: Mon, Jan 29 2007 1:54 am
Subject: Re: NBear使用时遇到参数是数组时的问题

就是gateway.*InSubQuery*方法,随便试试就能看到了。不是静态方法。

Teddy

On 1/29/07, 寻路者 <181443...@qq.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
寻路者  
View profile   Translate to Translated (View Original)
 More options Jan 29 2007, 2:43 am
From: "寻路者" <181443...@qq.com>
Date: Sun, 28 Jan 2007 23:43:05 -0800
Local: Mon, Jan 29 2007 2:43 am
Subject: Re: NBear使用时遇到参数是数组时的问题
终于找到了,不过看不明白InSubQuery里面每个参数的意思,能解释下么?

On 1月29日, 下午2时54分, Teddy <shijie...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Teddy  
View profile   Translate to Translated (View Original)
 More options Jan 29 2007, 2:45 am
From: Teddy <shijie...@gmail.com>
Date: Mon, 29 Jan 2007 15:45:18 +0800
Local: Mon, Jan 29 2007 2:45 am
Subject: Re: NBear使用时遇到参数是数组时的问题

举个例子:

gateway.FindArray<order>(order._.updatetime > DateTime.Parse("2006-1-1") &
gateway.InSubQuery<salesuser>(order._.userid, salesuser._.id, WhereClip.All),
OrderBy.Default)

总之InSubQuery返回的是一个WhereClip就是了。

Teddy

On 1/29/07, 寻路者 <181443...@qq.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google