Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

How I can return string, int, or bool from a Domain Service

Posted on 2010-09-14
9
2,611 Views
Last Modified: 2013-11-12
I´m using Visual Studio 2010, Silverligh 4.
How I can return string, int, bool from a Domain Service, once that the return always is  'System.ServiceModel.DomainServices.Client.InvokeOperation<???>.

Error      1      Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.InvokeOperation<int>' to 'int'

[Invoke]
public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
{
    NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
    return _NFe_C_emitBLL.Inserir(nFe_C_emit);
}

Thanks
0
Comment
Question by:Plexo
  • 5
  • 4
9 Comments
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 33679210
[Invoke]
public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
{
    NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
    return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
}
0
 

Author Comment

by:Plexo
ID: 33682469
It not accepts  return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
Something are returning, But I cant convert.

look the error:

Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.InvokeOperation<int>' to 'int'
0
 

Author Comment

by:Plexo
ID: 33682656
It not accepts  return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
Something are returning, But I cant convert.

look the error:

Cannot implicitly convert type 'System.ServiceModel.DomainServices.Client.InvokeOperation<int>' to 'int'

(XAML.cs)
        private void btnIncluir_Click(object sender, RoutedEventArgs e)
        {
            pNFe_C_emit("I", 1000, "78749991000105", "35965355904", "Plexo Informática Ltda", "Plexo");
        }

(DOMAIN SERVICE)
        [Invoke]
        public void InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
        {
            NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
            _NFe_C_emitBLL.Inserir(nFe_C_emit);
        }

(BLL)
        public int Inserir(NFe_C_emit _NFe_C_emit)
        {
            db.AddToNFe_C_emit(_NFe_C_emit);
            db.SaveChanges();
            return _NFe_C_emit.ID_Plexo;
        }
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 33683179
when you tried my code what is the error it gave ??
0
 

Author Comment

by:Plexo
ID: 33683848
Hi gauthampj

When I tried your code, I had the following error:

'int' does not contain a definition for 'Value' and no extension method 'Value' accepting a first argument of type 'int' could be found (are you missing a using directive or an assembly reference?)

        [Invoke]
        public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
        {
            NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
            return _NFe_C_emitBLL.Inserir(nFe_C_emit).Value;
        }

    public class NFe_C_emitBLL
    {
        private static NFeEntities db = new NFeEntities();
        public int Inserir(NFe_C_emit _NFe_C_emit)
        {
            db.AddToNFe_C_emit(_NFe_C_emit);
            db.SaveChanges();
            return _NFe_C_emit.ID_Plexo;
        }


0
 
LVL 29

Expert Comment

by:Gautham Janardhan
ID: 33683940
which line did you say the error was on.. can you post just that line ?
0
 

Author Comment

by:Plexo
ID: 33688027


Hi gauthampj
The error happens in Highlights line.
Domain Service
 [Invoke]
        public int InsertNFe_C_emit(NFe_C_emit nFe_C_emit)
        {
            NFe_C_emitBLL _NFe_C_emitBLL = new NFe_C_emitBLL();
           return _NFe_C_emitBLL.Inserir(nFe_C_emit);
       }

Class BLL
 public class NFe_C_emitBLL
    {
        private static NFeEntities db = new NFeEntities();
        public int Inserir(NFe_C_emit _NFe_C_emit)
        {
            db.AddToNFe_C_emit(_NFe_C_emit);
            db.SaveChanges();
            return _NFe_C_emit.ID_Plexo;
        }
    }
0
 
LVL 29

Accepted Solution

by:
Gautham Janardhan earned 500 total points
ID: 33689703
can you post the client code that is calling this service ?
i think that is where your error

you calling code should be something like

[Invoke]
public string GetInt()
{
   return 0;
}

and then

context.GetInt(new Action>(GetIntCompleted), null);

private void GetIntCompleted(InvokeOperation args)
{
   //your int is args.Value
}


0
 

Author Closing Comment

by:Plexo
ID: 33697941
Thanks
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question