Solved

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

Posted on 2010-09-14
9
2,596 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
Comment Utility
[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
Comment Utility
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
Comment Utility
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
 
LVL 29

Expert Comment

by:Gautham Janardhan
Comment Utility
when you tried my code what is the error it gave ??
0
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Plexo
Comment Utility
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
Comment Utility
which line did you say the error was on.. can you post just that line ?
0
 

Author Comment

by:Plexo
Comment Utility


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
Comment Utility
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
Comment Utility
Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
This article describes a technique for converting RTF (Rich Text Format) data to HTML and provides C++ source that does it all in just a few lines of code. Although RTF is coming to be considered a "legacy" format, it is still in common use... po…
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…
This video discusses moving either the default database or any database to a new volume.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now