.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

GenericCollection Strongly Typed on Retreval

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :WPF

When using Generics i keep hitting a situation where i'd like to be able to collectively store generic classes with out reference to the typed constraints applied to generics at the point of storing


The solution that seems feasible to me would be a Collection<TGeneric<>>:KeyedCollection<typeof(TType), TGeneric<TType>> where TGeneric would be the Generic class and TType would be the type applied to it

so as an example you have some generic class CLASS<T>{}

you create

GenericCollection<CLASS<>> col


Col.Add(new CLASS<int>)

Col.Add(new CLASS<double>)

Col.Add(new CLASS<string>)

then if you do


you would get back the CLASS<int> object in a type safe format


the question is is this possible under the CLR with out using refection (as far as I'm aware not, but i may be wrong)

if so how would you do it and if not does anyone else think it would be a valid and useful addition

Definition of a Beginner
Someone that is unaware of the rules that need to be obeyed

Definition of an Expert
Someone that know when and which rules to ignore

View Complete Post

More Related Resource Links

Introduction to strongly Typed Data Sets

This article teaches how to create a strongly-typed dataset class library in your C# database applications. Our objectives are as follows:

.Learn what an strongly-Typed Data Set is
.Let Visual Studio Create a ST Data Set
.(Semi)Manually create a ST Data Set using XSD (Xml Schema Definition)

Data Points: Efficient Coding With Strongly Typed DataSets


Someone once said to me that the hallmark of a good developer is the desire to spend time efficiently. Developers are continually pursuing ways to make coding easier and faster, and to reduce the number of errors.

John Papa

MSDN Magazine December 2004

How to create strongly typed datasets with access parameter queries



How can you create strongly typed datasets using an access database against access select statements that use parameters?

The problem is VS.Net doesn't allow select queries with parameters to be dragged onto a form, it only allows access queries without parameters!

I also tried the dataadapter wizard, but again it only allows me to select queries without parameters?

Many thanks in advance


Strongly Typed DataSet Cleanup

Hey all, I've looked around and I can't seem to find a good answer on this. Is there any cleanup needed on a strongly typed dataSet? I'm using DataSets as my DAL but I don't really have a BLL. I'm handling this in my code behind like this: Private PunchAdapter As New PunchDSTableAdapters.PUNCHIMPORTTableAdapter Dim LastPunch As String = PunchAdapter.GetLastPunch(PersonNUM) PunchAdapter.InsertPunch(PunchID, ReqCode, PersonNUM, txtDate.Text, txtTime.Text) I'm assuming it handles the opening and closing of the connetion? The adapter has a dispose method. Should I be using this? Is there any cleanup necessary or does the partial class (that inherits system.data.dataset) handle all of this? Thanks!

binding dictionary with strongly typed view

hey guys ,i m beginner in asp.net mvc , i have strongly typed view and i m passing my dictionary in view as :Dictionary<Guid,IYummyWebAppMVC.Models.Restaurant.Menu>>" %> Dictionary<Guid , MyApp.Models.Res.Menu>  how do i access this in html ?how do i iterate thru it and get value of both the items ?

strongly typed view - Complex Model

I have a class ProjectDetailModelView with       ProjctDetail (fields to display)        UserList - SelectList (for dropdown control)I pass in  Inherits="System.Web.Mvc.ViewPage<glossaryDB.Manager.ProjectDetailModelView>" %>       And I want to use something like the following:<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">    <h2>Project : Edit</h2>     <% Html.EnableClientValidation(); %>    <% using (Html.BeginForm()) { %>        <fieldset style="padding: 1em; margin: 0; border: solid 1px #999;">            <%= Html.ValidationSummary("Broken stuff:") %>               <%= Html.EditorForModel() %>            <input type="submit" value="  Submit  " />   

How to use connection string and strongly-typed dataset which exists in another project ?



i have a winform application with huge strongly-typed dataSet. Now, i've decided to create a web edition of my application and i want to use strongly-typed typed dataSet which exists in my winform application. also it's tableAdapters create with the connection string settings which stored in my winforms app.config.

my problem is that how to use strongly-typed dataset of my winform app with new connection string which exists in my web app ?

thanks in advance

Problem with SCOPE_IDENTITY in strongly typed datasets



I am developing an ASP.NET site and I am using strongly typed datasets and I am generating them automatically in Visual Studio 2008. I have been using TransactionScope to be able to use several table adapters from different datasets and update them in one transaction. When I create a new row, I use the update method in the table adapter to create new posts. The update method takes a dataset, datatable or a row as argument making them very easy to work with. After I have updated a row, I have generated a ExecuteScalarGetIdValue() call to get the latest inserted ID value. I use "SELECT SCOPE_IDENTITY" and it gives me an exception. When I try the query builder this SELECT SCOPE_IDENTITY is returning NULL. When I ask it in SQL Management Studio SQL Query window it returns a correct value. How can I get the correct value from the table adapter?

        id = this._event.ExecuteScalarGetIdValue();



      return true;

 Best regards, Janhe

Strongly typed view validation


I have a strongly typed view with my model being entity framework.  In my controller I check for ModelState.IsValid.  When I submit my form without a value for a column that does not allow nulls it crashes before it gets to the ModelState.IsValid line and the error is about not allowing nulls in the column.  Shouldn't this be what is handled by the ModelState.IsValid line?  I feel like I am missing something obvious. 

Strongly typed dataset exception handling


Hey everyone,

I'm currently working on a 3-tier ASP.NET application (UI, BLL & DAL). The DAL uses a strongly typed dataset that I've created with the VS Dataset Wizard. My question is, what is the best way to handle exceptions originating from the BLL and DAL classes. I googled a bit and it seems that the most commonly used practice is to create DALException and BLLException classes and throw your own message. Is this the way forward? Could you please indicate how this can be done for an automatically generated DAL? What are the best practices? Examples with code are highly appreciated!!



Using a partial in a strongly typed view


I have an application that is going to allow a user to create records of type Customer and Seller that have one section in common, but other fields that are unique to their types.

Both of these types will have an address block for their create view.

If I have a strongly typed Customer or Seller view, how can I use the view partial (containing the address block) that I've created? I've tried creating a view model, but I don't know how to have the create page inherit the Customer model and the addressBlock partial inherit the addressBlockForm partial model...

Hopefully, this makes sense, and thank you for any help.

Strongly typed view and viewModel


Hello together,

I have a question about strongly typed views.

I already have my business objects (based on the persistence framework xpo form dev express). These objects have some associations.

eg. an article can have some user comments


My question now is, should my strongly typed views directly base on this objects (even if these objects have many properties i never need to present)

or should i create additional classes containing only the properties of the objects which i like to present.

eg. articleViewModel and commentViewModel.

where a articleViewModel can have associations with multiple commentViewModel

The advantage which i see in the second example is, that i can easier validate the viewModels.

However it means a lot of extra work, because i need to create for all objects which i like to present a viewModel with the corresponding

associations and properties.

Thanks a lot!

Regards Vincenzo

MVC2: Change the default generated HTML when creating a strongly typed view


Is there any way to change the HTML that is generated by default when you create a strongly typed view in MVC2?

I currently get a structure like this:

            <div class="editor-label">
                <%: Html.LabelFor(model => model.category_id) %>
            <div class="editor-field">
                <%: Html.TextBoxFor(model => model.category_id) %>
                <%: Html.ValidationMessageFor(model => model.category_id) %>

I want to change it to a structure like this:

                <div><%: Html.ValidationMessageFor(model => model.user_login) %></div>
                <div><%: Html.LabelFor(model => model.user_login) %></div>
                <div><%: Html.TextBoxFor(model => model.user_login) %></div>

Timeout on dataadapter.Fill on strongly typed dataset


Hi friends,

               Error message shown "timeout expired.the timeout period elapsed prior to completion of the operation or the server is not responding "

                on filling the strongly typed dataset(ie. dataadapter.Fill(dataset.tablename)).  plz help me




Strongly Typed HtmlHelpers and View Models



I am not sure why this happens, but when I have an Html.TextBoxFor(model => model.SomeObject.SomeProperty), when I post, the property of that object is always null.

When I look at the markup generated, I see <input type="text" name="SomeObject_SomeProperty" id="SomeObject.SomeProperty" value = "" />

If I change the helper to Html.TextBoxFor(model => model.SomeObject.SomeProperty, new {id = "SomeProperty"}) the controller is then able to pick the value up. Why is this happening? I feel as though I shouldn't have to be specifiying the id for the textbox as it works when fine when not using child objects on a view model, IE <%: HtmlTextBoxFor(model => model.SomeProperty) %>.

Upload with strongly-typed view - Create Method



How to can upload a file to database with strongly typed view - create method?

Picture is a binary db column

<%: Html.TextBoxFor(Function(model) model.Resim)%>


 How i can translate "TextBoxFor" to "UploadFileFor"?

Downcasting to base class Strongly typed view


I have the following entity object:

    public class ForumPost
            public virtual int ForumPostId { get; set; }
            public virtual int LoginId { get; set; }
            public virtual string Body { get; set; }

Then I have page that would has a list of ForumPost(s) and and edit option, all on one page. To achieve this I've created a CommentsViewModel that extends "ForumPost" class like so:

    public class CommentsViewModel : ForumPost
        public IPagedList<ForumPost> ForumPostList { get; set; }

This way on my view I can have a list of ForumPost(s) and a form that would edit the post.

This is what i see in the debug mode right before the save call:

The problem is that when I try to Save/Update I get the following error:

I already tried doing this:



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend