?
Solved

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

Posted on 2010-09-14
9
Medium Priority
?
2,665 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
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
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 2000 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

Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

Question has a verified solution.

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

This article describes how to add a user-defined command button to the Windows 7 Explorer toolbar.  In the previous article (http://www.experts-exchange.com/A_2172.html), we saw how to put the Delete button back there where it belongs.  "Delete" is …
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
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…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

850 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