Search Results

Search found 26126 results on 1046 pages for 'generic service contract'.

Page 109/1046 | < Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >

  • How to populate a generic list of objects in C# from SQL database

    - by developr
    I am just learning ASP.NET c# and trying to incorporate best practices into my applications. Everything that I read says to layer my applications into DAL, BLL, UI, etc based on separation of concerns. Instead of passing datatables around, I am thinking about using custom objects so that I am loosely coupled to my data layer and can take advantage of intellisense in VS. I assume these objects would be considered DTOs? First, where do these objects reside in my layers? BLL, DAL, other? Second, when populating from SQL, should I loop through a data reader to populate the list or first fill a data table, then loop through the table to populate the list? I know you should close the database connection as soon as possible, but it seems like even more overhead to populate the data table and then loop through that for the list. Third, everything I see these days says use Linq2SQL. I am planning to learn Linq2SQL, but at this time I am working with a legacy database that doesn't have foreign keys setup and I do not have the ability to fix it atm. Also, I want to learn more about c# before I start getting into ORM solutions like nHibernate. At the same time I don't want to type out all the connection and SQL plumbing for every query. Is it ok to use the Enterprise DAAB for now?

    Read the article

  • Restlet vs Spring MVC for Restful web service

    - by zachariahyoung
    I'm researching how best to create a Restful web service on Google app engine. My end goal is to have an Android application call a web service on GAE to post and get data. At this point I not sure what the best approach is. What I know at this point is Spring MVC 3 provide the ability to create web service but it does not provide a full implementation of JAX-RS. I also have read a few blog that talk about how Spring and Restlet can be integrated together. On the other side I have read that I could only use Restlet in GAE. I would also like provide a light web interface for users to view their posted data So my questions are the following. 1. Should I just use Restlet. 2. Should I just use Spring MVC to provide my Restful web service. 3. Should I use Spring and Restlet together. At this point I think I should invest my time in Restlet because that seems to be the best approach for calling web services in Android. I'm also debating if Spring MVC is just over kill. Any thoughts would be helpful.

    Read the article

  • Building a generic page "Query Analyzer" like in Asp.net with SMO

    - by Rodrigo
    Hello, I'm build a web page in ASP.net is supposed to work just like Query Analyzer. It has basically a textarea to input the sql command, and an Execute button. I'm using SMO to execute the command in the database, as follows: //Create object SMO Microsoft.SqlServer.Management.Smo.Server server = new Microsoft.SqlServer.Management.Smo.Server(new Microsoft.SqlServer.Management.Common.ServerConnection(oConn)); //To execute the command server.ConnectionContext.ExecuteNonQuery(tbx_cmd.Text); //OR myDataset = server.ConnectionContext.ExecuteWithResults(tbx_cmd.Text); The problem is that the textarea command can contain anything, from a stored procedure (with GO's statements) and any select command that return resultsets, just like Query Analyzer. But, if I have GO statements, I only can perform the query using ExecuteNonQuery method. If I use the ExecuteWithResults method, it raises errors because of the GO statements. And if I want the resultsets to be available, of course I can only use the ExecuteWithResults method. Does anybody knows how can I do to execute the same command texts at the same time? Thank you!

    Read the article

  • Create an ASMX web service from a WSDL file

    - by metanaito
    I have a WSDL file and I am trying to create a web service that conforms to the WSDL. I've created clients using WSDL files that consume an existing service, but I've never created a web service that needed to follow a specific WSDL. I've gone as far as using: wsdl.exe mywsdl.wsdl /l:VB /serverInterface Now I've got a .vb file generated from that WSDL. However I am not sure what I'm supposed to do with this VB file. It looks like it's got a public interface in there but no class that implements the interface. It also has a bunch of partial classes for the types in the WSDL. I was expecting there to be some sort of stub where I put in the code to complete the service calls. I've only created simple web services before and none of them used public interfaces so I'm unfamiliar with what is going on here. At this point I'm not sure how I use the generated .vb file and make it work with an .asmx file and what additional coding is needed to complete the interface.

    Read the article

  • WCF Security in a Windows Service

    - by Alphonso
    I have a WCF service which can run as Console App and a Windows Service. I have recently copied the console app up to a W2K3 server with the following security settings: <wsHttpBinding> <binding name="ServiceBinding_Security" transactionFlow="true" > <security mode="TransportWithMessageCredential" > <message clientCredentialType="UserName" /> </security> </binding> </wsHttpBinding> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="Custom" customUserNamePasswordValidatorType="Common.CustomUserNameValidator, Common" /> </serviceCredentials> Security works fine with no problems. I have exactly the same code, but running in a windows service and I get the following error when I try to call any of the methods from a client: System.ServiceModel.Security.MessageSecurityException was unhandled Message="An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail." Source="mscorlib" StackTrace: Server stack trace: at System.ServiceModel.Channels.SecurityChannelFactory`1.SecurityRequestChannel.ProcessReply(Message reply, SecurityProtocolCorrelationState correlationState, TimeSpan timeout) ...... (lots of stacktrace info - not very useful) InnerException: System.ServiceModel.FaultException Message="An error occurred when verifying security for the message." The exception tells me nothing. I'm assuming that it has something to do with acces to system resources from the Windows Service. I've tried running it under the same account as the console app, but no luck. Does anyone have any ideas?

    Read the article

  • WCF service errors after installing WindowsXP updates

    - by niao
    Greeting, today before I start working on my application I updated my WinXP. After all updates have been installed my WCF service stop working. There is a following error when I try to open service.svc file in the browser: Configuration Error Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately. Parser Error Message: An error occurred creating the configuration section handler for system.serviceModel/bindings: Could not load type 'System.Security.Authentication.ExtendedProtection.Configuration.ExtendedProtectionPolicyElement' from assembly 'System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Source Error: Line 131: </behaviors> Line 132: Line 133: <bindings> Line 134: <wsHttpBinding> Line 135: <binding name="MyWSHttpBinding" maxReceivedMessageSize="2147483647"> The colleague of my tried to run the same service before update and it works fine. He has the same problem after installing updates. Can someone please help me?

    Read the article

  • Using a Generic Repository pattern with fluent nHibernate

    - by alex
    I'm currently developing a medium sized application, which will access 2 or more SQL databases, on different sites etc... I am considering using something similar to this: http://mikehadlow.blogspot.com/2008/03/using-irepository-pattern-with-linq-to.html However, I want to use fluent nHibernate, in place of Linq-to-SQL (and of course nHibernate.Linq) Is this viable? How would I go about configuring this? Where would my mapping definitions go etc...? This application will eventually have many facets - from a WebUI, WCF Library and Windows applications / services. Also, for example on a "product" table, would I create a "ProductManager" class, that has methods like: GetProduct, GetAllProducts etc... Any pointers are greatly received.

    Read the article

  • Generic foreach loop in C#.

    - by mcoolbeth
    The compiler, given the following code, tells me "Use of unassigned local variable 'x'." Any thoughts? public delegate Y Function<X,Y>(X x); public class Map<X,Y> { private Function<X,Y> F; public Map(Function f) { F = f; } public Collection<Y> Over(Collection<X> xs){ List<Y> ys = new List<Y>(); foreach (X x in xs) { X x2 = x;//ys.Add(F(x)); } return ys; } }

    Read the article

  • Avoiding unsafe cast for generic situation involving runtime passing of class

    - by Bart van Heukelom
    public class AutoKeyMap<K,V> { public interface KeyGenerator<K> { public K generate(); } private KeyGenerator<K> generator; public AutoKeyMap(Class<K> keyType) { // WARNING: Unchecked cast from AutoKeyMap.IntKeyGen to AutoKeyMap.KeyGenerator<K> if (keyType == Integer.class) generator = (KeyGenerator<K>) new IntKeyGen(); else throw new RuntimeException("Cannot generate keys for " + keyType); } public void put(V value) { K key = generator.generate(); ... } private static class IntKeyGen implements KeyGenerator<Integer> { private final AtomicInteger ai = new AtomicInteger(1); @Override public Integer generate() { return ai.getAndIncrement(); } } } In the code sample above, what is the correct way to prevent the given warning, without adding a @SuppressWarnings, if any?

    Read the article

  • Invoking EventHandler generic, TargetParameterCountException

    - by Am
    Hi, I have a DirectoryMonitor class which works on another thread. It has the following events declared: public class DirectoryMonitor { public event EventHandler<MonitorEventArgs> CreatedNewBook; public event EventHandler ScanStarted; .... } public class MonitorEventArgs : EventArgs { public Book Book { get; set; } } There is a form using that monitor, and upon receiving the events, it should update the display. Now, this works: void DirectoryMonitor_ScanStarted(object sender, EventArgs e) { if (InvokeRequired) { Invoke(new EventHandler(this.DirectoryMonitor_ScanStarted)); } else {...} } But this throws TargetParameterCountException: void DirectoryMonitor_CreatedNewBook(object sender, MonitorEventArgs e) { if (InvokeRequired) { Invoke(new EventHandler<MonitorEventArgs>(this.DirectoryMonitor_CreatedNewBook)); } else {...} } What am I missing?

    Read the article

  • Generic styles for DataGridTemplateColumn Headers & Cells

    - by user557765
    I am struggling to define templates for my DataGrid columns. Here is the code that I have working at the moment: <t:DataGrid.Columns> <t:DataGridTemplateColumn Width="75" > <t:DataGridTemplateColumn.HeaderTemplate> <DataTemplate> <TextBlock Style="{StaticResource FieldNameVertical}" Text="Date" /> </DataTemplate> </t:DataGridTemplateColumn.HeaderTemplate> <t:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Style="{StaticResource FieldValue}" Text="{Binding ModifiedDate, StringFormat='{}{0:MM/dd/yyyy}'}" /> </DataTemplate> </t:DataGridTemplateColumn.CellTemplate> </t:DataGridTemplateColumn> .. .. .. </t:DataGrid.Columns> I would like to define HeaderTemplate & CellTemplate as reusable styles -- so that each column would be as brief as something like this: <t:DataGrid.Resources> <DataTemplate x:Key="dgHeaderStyle"> <TextBlock Style="{StaticResource FieldNameVertical}" Text="{Binding}" /> </DataTemplate> <DataTemplate x:Key="dgCellStyle"> <TextBlock Style="{StaticResource FieldValue}" Text="{Binding}" /> </DataTemplate> </t:DataGrid.Resources> <t:DataGrid.Columns> <t:DataGridTemplateColumn Width="75" Header="Date" Binding="{Binding ModifiedDate, StringFormat='{}{0:MM/dd/yyyy}'}" HeaderTemplate="{StaticResource dgHeaderStyle}" CellTemplate="{StaticResource dgCellStyle}" /> <t:DataGridTemplateColumn Width="100" Header="Dealer" HeaderTemplate="{StaticResource dgHeaderStyle}" CellTemplate="{StaticResource dgCellStyle}" /> ... </t:DataGrid.Columns> Every attempt I make has failed. I had hoped to implement something like the "solution" snippet in the initial entry of WPF DataGrid HeaderTemplate Mysterious Padding. However, I can't seem to adapt it to what I'm doing.

    Read the article

  • Java Builder pattern with Generic type bounds

    - by I82Much
    Hi all, I'm attempting to create a class with many parameters, using a Builder pattern rather than telescoping constructors. I'm doing this in the way described by Joshua Bloch's Effective Java, having private constructor on the enclosing class, and a public static Builder class. The Builder class ensures the object is in a consistent state before calling build(), at which point it delegates the construction of the enclosing object to the private constructor. Thus public class Foo { // Many variables private Foo(Builder b) { // Use all of b's variables to initialize self } public static final class Builder { public Builder(/* required variables */) { } public Builder var1(Var var) { // set it return this; } public Foo build() { return new Foo(this); } } } I then want to add type bounds to some of the variables, and thus need to parametrize the class definition. I want the bounds of the Foo class to be the same as that of the Builder class. public class Foo<Q extends Quantity> { private final Unit<Q> units; // Many variables private Foo(Builder<Q> b) { // Use all of b's variables to initialize self } public static final class Builder<Q extends Quantity> { private Unit<Q> units; public Builder(/* required variables */) { } public Builder units(Unit<Q> units) { this.units = units; return this; } public Foo build() { return new Foo<Q>(this); } } } This compiles fine, but the compiler is allowing me to do things I feel should be compiler errors. E.g. public static final Foo.Builder<Acceleration> x_Body_AccelField = new Foo.Builder<Acceleration>() .units(SI.METER) .build(); Here the units argument is not Unit<Acceleration> but Unit<Length>, but it is still accepted by the compiler. What am I doing wrong here? I want to ensure at compile time that the unit types match up correctly.

    Read the article

  • Create a Generic IEnumerable<T> given a IEnumerable and the member datatypes

    - by ilias
    Hi, I get an IEnumerable which I know is a object array. I also know the datatype of the elements. Now I need to cast this to an IEnumerable<T, where T is a supplied type. For instance IEnumerable results = GetUsers(); IEnumerable<T> users = ConvertToTypedIEnumerable(results, typeof(User)); I now want to cast/ convert this to IEnumerable<User. Also, I want to be able to do this for any type. I cannot use IEnumerable.Cast<, because for that I have to know the type to cast it to at compile time, which I don't have. I get the type and the IEnumerable at runtime. - Thanks

    Read the article

  • Japanese text garbled while passing to a http restlet service

    - by satish-gunuputi
    Hi , I have a perl client which is calling a http restlet service (put method). Some of the parameters in this call contain japanese text. when I printed the contents of these request parameters in the restlet service I found these chars garbled ! This is my PERL client code: my %request_headers = ( 'DocumentName' => $document_name, --> This name is a JAPANESE String 'DocumentDescription' => 'Test Japanese Chars', 'content-length' => 200, 'Content-Type' => 'application/octet-stream; charset=utf-8', 'User-Agent' => "JPCharTester", ); $s-write_request('PUT', '/test-document/TEST/TEST_DOCUMENT' , %request_headers, $content); in this call both the values of $context and $document_name are JAPANESE Strings. But ONLY the document_name is received as garbled in my backend service. Here goes the Service code: String URL_ENCODING = "UTF-8"; String documentName = requestHeaders.getFirstValue("DocumentName"); System.out.println("Encoded Document Name : "+documentName+" <<<"); --> documentName is garbled here try { documentName = URLDecoder.decode(documentName, URL_ENCODING); System.out.println(>>> Decoded Document Name : "+documentName+" <<<"); --> documentName is garbled here } catch (java.io.UnsupportedEncodingException ex) { throwException(ex.getMessage(), Status.SERVER_ERROR_INTERNAL, ex); } both the above log statements printed GARBLED TEXT !! Can someone tell me what is the mistake I am doing and how to fix this ? Thanks in advance for your help. Regards, Satish.

    Read the article

  • Java generics parameters with base of the generic parameter

    - by Iulian Serbanoiu
    Hello, I am wondering if there's an elegant solution for doing this in Java (besides the obvious one - of declaring a different/explicit function. Here is the code: private static HashMap<String, Integer> nameStringIndexMap = new HashMap<String, Integer>(); private static HashMap<Buffer, Integer> nameBufferIndexMap = new HashMap<Buffer, Integer>(); // and a function private static String newName(Object object, HashMap<Object, Integer> nameIndexMap){ .... } The problem is that I cannot pass nameStringIndexMap or nameBufferIndexMap parameters to the function. I don't have an idea about a more elegant solution beside doing another function which explicitly wants a HashMap<String, Integer> or HashMap<Buffer, Integer> parameter. My question is: Can this be made in a more elegant solution/using generics or something similar? Thank you, Iulian

    Read the article

  • OData / WCF Data Service - HTTP 500 Error

    - by Eric
    I have created an OData/WCF service using Visual Studio 2010 on Windows XP SP3 with all current patches installed. When I click on "view in browser", the service opens and I see the 3 tables from my EF model. However, when I add a table name ("Commands" in this case) to the end of the query string, rather than seeing the data from the table, I get an HTTP 500 error. (This error (HTTP 500 Internal Server Error) means that the website you are visiting had a server problem which prevented the webpage from displaying.). I have not only followed the examples from 2 sites, but have also tried running the sample application that the blog poster sent me (that works on his machine), and still am not having any luck. The blog post is at Exposing OData from an Entity Framework Model Does anyone have an idea why this is occurring and how to resolve it? Here is the output of the "View in Browser": <?xml version="1.0" encoding="utf-8" standalone="yes" ?> - <service xml:base="http://localhost:1883/VistaDBCommandService.svc/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:app="http://www.w3.org/2007/app" xmlns="http://www.w3.org/2007/app"> - <workspace> <atom:title>Default</atom:title> - <collection href="Commands"> <atom:title>Commands</atom:title> </collection> - <collection href="Databases"> <atom:title>Databases</atom:title> </collection> - <collection href="Statuses"> <atom:title>Statuses</atom:title> </collection> </workspace> </service> ============================= Thanks, Eric

    Read the article

  • RESTful WCF Data Service Authentication

    - by Adrian Grigore
    Hi, I'd like to implement a REST api to an existing ASP.NET MVC website. I've managed to set up WCF Data services so that I can browse my data, but now the question is how to handle authentication. Right now the data service is secured via the site's built in forms authentication, and that's ok when accessing the service from AJAX forms. However, It's not ideal for a RESTful api. What I would like as an alternative to forms authentication is for the users to simply embed the user name and password into the url to the web service or as request parameters. For example, if my web service is usually accessible as http://localhost:1234/api.svc I'd like to be able to access it using the url http://localhost:1234/api.svc/{login}/{password} So, my questions are as follows: Is this a sane approach? If yes, how can I implement this? It seems trivial redirecting GET requests so that the login and password are attached as GET parameters. I also know how to inspect the http context and use those parameters to filter the results. But I am not sure if / how the same approach could be applied to POST, PUT and DELETE requests. Thanks, Adrian

    Read the article

  • Best way to change jqGrid rowNum from ALL to -1 before pass to a web service

    - by Billyhole
    I'm looking to find the best way to allow users to choose to show ALL records in a jqGrid. I know that a -1 value passed for the rows parameter denotes ALL, but I want the word "ALL" not a -1 to appear in the rowList select element, ie. rowList: [15, 50, 100, 'ALL']. I'm passing the grid request to a web service which accepts an int for "rows", and I'm trying find how and when I should change the user selected value of "ALL" to a -1 before it gets sent to the web service. Below is my cleaned up grid code. I tried some various code blocks before my $.ajax in the datatype function. But most attempts just seemed like I have to be doing this the most convoluted way I possibly could. For example, datatype: function(postdata) { if ($("#gridTableAssets").jqGrid('getGridParam', 'rowNum') == 'ALL') { $("#gridTableAssets").appendPostData({ "rows": -1, "page": 1 }); } $.ajax({... But doing that seemed to cause the actual "page" GridParam to be nulled out on subsequent grid actions, forcing me handle that in other places. There just seems like this is something that would be frequently done out there and have clean way of doing it. Cleaned grid code: $("#gridTableAssets").jqGrid({ datatype: function(postdata) { $.ajax({ url: "/Service/Repository.asmx/GetAssets", data: JSON.stringify(postdata), type: 'POST', contentType: "application/json; charset=utf-8", error: function(XMLHttpRequest, textStatus, errorThrown) { alert('error'); }, success: function(msg) { var assetsGrid = $("#gridTableAssets")[0]; assetsGrid.addJSONData(JSON.parse(msg)); ... } }); }, ... pager: $('#pagerAssets'), rowNum: 15, rowList: [15, 50, 100, 'ALL'], ... onPaging: function(index, colindex, sortorder) { SessionKeepAlive(); } }); And here is the web service [WebMethod] public string GetAssetsOfAssetStructure(bool _search, int rows, int page, string sidx, string sord, string filters)

    Read the article

  • Generic HTTP Handler in ASP.Net

    - by Bruno Brant
    Hello all, I want to write a custom HTTP Handler in ASP.Net (I'm using C# currently) that filters all requests to, say, .aspx files, and then, depending on the page name that comes with the requests, I redirect the user to a page. So far, I've written a handler that filter "*", that is, everything. Let's say I receive a request for "Page.aspx", and want to send the user to "AnotherPage.aspx". So I call Redirect on that response and pass "AnotherPage.aspx" as the new page. The problem is that this will once more trigger my handler, which will do nothing. This will leave the user without any response. So, is there a way to send the request to the other handlers (cascade the message) once I've dealt with it? Thanks, Bruno

    Read the article

  • Is it possible to create a generic Util Function to be used in Eval Page

    - by Nassign
    I am currently binding a Nullable bit column to a listview control. When you declare a list view item I need to handle the case when the null value is used instead of just true or false. <asp:Checkbox ID="Chk1" runat="server" Checked='<%# HandleNullableBool(Eval("IsUsed")) %>' /> Then in the page I add a HandleNullableBool() function inside the ASPX page. protected static bool HandleNullableBool(object value) { return (value == null) ? false : (bool)value; } This works fine but I need to use this in several pages so I tried creating a utility class with a static HandleNullableBool. But using it in the asp page does not work. Is there a way to do this in another class instead of the ASPX page? <asp:Checkbox ID="Chk1" runat="server" Checked='<%# Util.HandleNullableBool(Eval("IsUsed")) %>' />

    Read the article

  • Modeling a Generic Relationship in a Database

    - by StevenH
    This is most likely one for all you sexy DBAs out there: How would I effieciently model a relational database whereby I have a field in an "Event" table which defines a "SportType". This "SportsType" field can hold a link to different sports tables E.g. "FootballEvent", "RubgyEvent", "CricketEvent" and "F1 Event". Each of these Sports tables have different fields specific to that sport. My goal is to be able to genericly add sports types in the future as required, yet hold sport specific event data (fields) as part of my Event Entity. Is it possible to use an ORM such as NHibernate / Entity framework which would reflect such a relationship? I have thrown together a quick C# example to express my intent at a higher level: public class Event<T> where T : new() { public T Fields { get; set; } public Event() { EventType = new T(); } } public class FootballEvent { public Team CompetitorA { get; set; } public Team CompetitorB { get; set; } } public class TennisEvent { public Player CompetitorA { get; set; } public Player CompetitorB { get; set; } } public class F1RacingEvent { public List<Player> Drivers { get; set; } public List<Team> Teams { get; set; } } public class Team { public IEnumerable<Player> Squad { get; set; } } public class Player { public string Name { get; set; } public DateTime DOB { get; set;} }

    Read the article

  • Self closing Html Generic Control?

    - by Chalkey
    I am writing a bit of code to add a link tag to the head tag in the code behind... i.e. HtmlGenericControl css = new HtmlGenericControl("link"); css.Attributes["rel"] = "Stylesheet"; css.Attributes["type"] = "text/css"; css.Attributes["href"] = String.Format("/Assets/CSS/{0}", cssFile); to try and achieve something like... <link rel="Stylesheet" type="text/css" href="/CSS/Blah.css" /> I am using the HtmlGenericControl to achieve this... the issue I am having is that the control ultimatly gets rendered as... <link rel="Stylesheet" type="text/css" href="/CSS/Blah.css"></link> I cant seem to find what I am missing to not render the additional </link>, I assumed it should be a property on the object. Am I missing something or is this just not possible with this control? Thanks

    Read the article

  • Casting generics and the generic type

    - by Kragen
    Consider, I have the following 3 classes / interfaces: class MyClass<T> { } interface IMyInterface { } class Derived : IMyInterface { } And I want to be able to cast a MyClass<Derived> into a MyClass<IMyInterface> or visa-versa: MyClass<Derived> a = new MyClass<Derived>(); MyClass<IMyInterface> b = (MyClass<IMyInterface>)a; But I get compiler errors if I try: Cannot convert type 'MyClass<Derived>' to 'MyClass<IMyInterface>' I'm sure there is a very good reason why I cant do this, but I can't think of one. As for why I want to do this - The scenario I'm imagining is one whereby you ideally want to work with an instance of MyClass<Derived> in order to avoid lots of nasty casts, however you need to pass your instance to an interface that accepts MyClass<IMyInterface>. So my question is twofold: Why can I not cast between these two types? Is there any way of keeping the niceness of working with an instance of MyClass<Derived> while still being able to cast this into a MyClass<IMyInterface>?

    Read the article

< Previous Page | 105 106 107 108 109 110 111 112 113 114 115 116  | Next Page >