English 中文(简体)
从客户获取域名中的习俗物体
原标题:Accessing custom objects in DomainService from client

我正在利用域网服务,从银星客户数据库中收集数据。

域名 我补充说:

[EnableClientAccess()]
public class Product
{
    public int productID;
    public string productName;        
    public List<Part> Parts = new List<Part>(); //Part is already present in Model designer
}

域名1级 我添加了一种新方法,重新收集习俗类别物体:

[EnableClientAccess()]
 public class DomainService1 : LinqToEntitiesDomainService<HELPERDBNEWEntities1>
 {
     ...
        public List<Product> GetProductsList(...)
        {
            List<Product> resultProducts = new List<Product>();
            ...
            return resultProducts;
        }
 }

来自银灯客户 我试图利用这种方法:

DomainService1 ds1 = new DomainService1();
var allproductList = ds1.GetProductsList(...);
ds1.Load<SLProduct>(allproductList).Completed += new EventHandler(Load_Completed); //Not correct usage

然而,采用新方法并不是正确的。 因此,我增加了房地产服务业的新产品类别。 c 必须有高效的分类。 我无法使用实体框架自动产生的模型级。

我如何把新方法称作客户?

问题回答

我认为,还有一个类似的问题,这里有一个答案:

房地产服务能否退回单一习俗类型?

此外,这里还就在域服务中增加习俗方法这一总体问题进行了一些讨论:

http://forums.silverlight.net/t/159292.aspx/1

虽然我不知道你所说的“这不是说新方法的正确方式”,或者如果你重新发现任何错误,那么我可能认为某些工作守则可能有所帮助。

My POCO

    public class GraphPointWithMeta
{
    [Key]
    public Guid PK { get; set; }
    public string SeriesName { get; set; } 
    public string EntityName { get; set; }
    public double Amount { get; set; }

    public GraphPointWithMeta(string seriesName, string entityName, double amount)
    {
        PK = Guid.NewGuid();
        SeriesName = seriesName;
        EntityName = entityName;
        Amount = amount;
    }

    // Default ctor required.
    public GraphPointWithMeta()
    {
        PK = Guid.NewGuid();
    }
}

域名服务中的一种方法(有效校正本级)

        public IEnumerable<GraphPointWithMeta> CallingActivityByCommercial()
    {
        List<GraphPointWithMeta> gps = new List<GraphPointWithMeta>();
        // ...
        return gps;
    }

吸引银星客户,如

ctx1.Load(ctx1.CallingActivityByCommercialQuery(), CallingActivityCompleted, null);

client call back method

        private void CallingActivityCompleted(LoadOperation<GraphPointWithMeta> lo)
    {
        // lo.Entities is an IEnumerable<GraphPointWithMeta>            
    }

我不清楚贵产品类别是否为实际实体。 从定义的角度看,它似乎不是一个实体。 我的回答是,这不是一个实体。 你们需要将数据成员Attribute用于贵产品财产,你将装上产品清单——装上实体Quries(在服务方面是合格的)。 你们只想像这一点(次要方面):

void GetProductList( Action<InvokeOperation<List<Product>>> callback)
{
    DomainService ds1 = new DomainService();
    ds1.GetProductsList(callback, null);//invoke operation call
}

域服务(服务方)方法需要InvokeAttribute,希望:

[EnableClientAccess]
public class MyDomainService
{
    [Invoke]
    public List<Product> GetProductList()
    {
        var list = new List<Product>();
        ...
        return list;
    }
}

And here is how your Product class might be defined (if it is not an entity):

public class Product
{
   [DataMember]
   public int productID;
   [DataMember]
   public string productName;        
   [DataMember]
   public List<Part> Parts = new List<Part>(); // you might have some trouble here.
                           //not sure if any other attributes are needed for Parts,
                           //since you said this is an entity; also not sure if you 
                           //can even have a list of entities or it needs to be an
                           //entity collection or what it needs to be.  You might
                           //have to make two separate calls - one to get the products
                           //and then one to get the parts.
}

和我一样,我不知道产品从......继承什么产品。 希望这一帮助。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签