Mvc - None Of The Generated Classes From Subsonic For Data Are Available
Jul 28, 2010
I have an MVC project setup, and I've brought the subsonic Active Record templates into my project, and they generated successfully and I can use the subsonic classes to access my database. However, how do I create a strongly typed view using the subsonic generated classes? When I select "add View" and I check the checkbox to create a strongly-typed view, none of the generated classes from subsonic for my data are available.
View 2 Replies
Similar Messages:
Jan 11, 2010
I am new to LINQ. when we drag tables we get a dbml file and designer file.
For example DataClasses1.dbml and DataClasses1.designer.cs.
Once we have them then we can start using our LINQ Queries.
In my company project I do not see this designer files and instead there are .tt files which were used as templates to greate ABC.generated.cs files. Is this same as designer class?
View 3 Replies
May 14, 2010
Technically I have the Data Annoations working with Linq to SQL classes - the problem is when validation
passes. When UpdateModel() tries to do its thing i can an error:The model of type 'MyProject.Models.Employee' could not be updated.What i did was i created a partial class for Employee (that is generated by linq to sql), then stuck a Meta Data class on top of it for the validation
[Code]....
And in my master page i include
<script type="text/javascript" src="/Scripts/jquery.validate.min.js"></script>
View 9 Replies
Sep 16, 2010
I have written a t4 template that basically replaces the work done by StronglyTypedResourceBuilder to give design time access to string resources as properties of classes, one class per resource file. Why? Well I needed to add some customer code that handles string token substitution and a few other customizations. Anyway, the template is working out really well and I may blog on it soon.
In the mean time though, following a common pattern, I have one .resx file for each view, master page, controller, etc. I would really like my t4 template to add a property to each such entity that gives quick access the custom resource class associated with it. For controllers this is easy. T4MVC is ensuring that they are a all declared partial. All I need to do is create the appropriate partial class in my output that declares a readonly property that returns an instance of the appropriate generated resource class.
The Problem:
I would like to do the same thing, inject generated code, into my views. Were this traditional ASP.Net, each .aspx page would have a .aspx.cs page and possibly an .aspx.designer.cs page that are all partial classes extending in the aspx page's class definition. There is no such thing by default in MVC and for good reason. However, I think for my purposes, if there is a way to do this, it would be the way to go.
I could subclass ViewPage and add a generic type parameter and a property that returns the class of that type but that has certain complications. I think adding auto generated code to each view via partial class (that is what partials are for after all) is the way to go.
I have made a basic attempt. I have created a .aspx.cs file for a view and placed a code behind attribute in the page declaration but the class generated from the view seems to reside in a different assembly any my "partial class" ends up as its own class in the same assembly as all my other code.
View 2 Replies
Apr 5, 2010
Is there a way to add/delete/update the default classes (for instance AspNet-Menu-WithChildren,AspNet-Menu-NonLink ) of the html generated by the asp.net menu or treeview control? I am using CSSAdapters so the menu control renders in a list format instead of table format.
View 1 Replies
May 17, 2010
I am following the Nerd Dinner tutorial as I'm learning ASP.NET MVC, and I am currently on Step 3: Building the Model. One part of this section discusses how to integrate validation and business rule logic with the model classes. All this makes perfect sense. However, in the case of this source code, the author only validates one class: Dinner.
What I am wondering is, say I have multiple classes that need validation (Dinner, Guest, etc). It doesn't seem smart to me to repeatedly write these two methods in the partial class:
[code]....
This doesn't "feel" right, but I wanted to check with SO to get opinions of individuals smarter than me on this. I also tested it out, and it seems that the partial keyword on the OnValidate method is causing problems (understandably so). This doesn't seem possible to fix (but I could very well be wrong).
View 1 Replies
Aug 11, 2010
I don't know if this has to do with how FindControl works or how scope works. But my base class is having a hard time seeing the fields of child classes. Currently I'm planning have the derived class set a property in the base class, but there are a lot of derived classes, so that isn't a very attractive solution.
[code]....
View 4 Replies
Mar 25, 2010
i try to use subsonic 3.0 but i can not do that. i decided to use subsonic.2.0. So i try to make it i can not :(
my Web Config :
[Code]....
also look this article: what is error? [URL]
View 1 Replies
Mar 24, 2010
Can I use VB and C# classes together in the same asp.net 3.5 project?
View 3 Replies
Jun 23, 2010
Is there a way to set the command timeout for everything generated by subsonic?
View 1 Replies
Dec 15, 2010
I'm curious as to what people consider better practice, between duplicating model structure in the view model and using a mapping tool to move data between the two, or aggregate the model inside the view model, i.e. have a property on the view model class that is a reference to the actual model. Which is considered a better approach in general?
View 1 Replies
Mar 20, 2010
Does anyone know how I can concatenate two columns in my subsonic datasource? I want to display a first and last name in this dropdownlist but I don't want to put them in the same SQL column.
View 2 Replies
Mar 7, 2011
I'm working against a database that wasn't designed by me and in all the tables there is a CreatedBy field that is an int. Now when I generate against this db i get all kinds of errors because subsonic is expecting that field to be a varchar.I don't particularly want to go and rename the field in all of these tables so I was hoping there was a way to "alter" or change the internal convention (without getting into the source) in subsonic.Has anyone been able/done this in subsonic 3.0.4??EDIT: I'm using the active record model in subsonic 3
View 1 Replies
Dec 26, 2010
I'm creating a small forum for my CMS and I'm using subsonic 2.2 as my DAL.
I'm loading my theads like this:
DAL.ForumThread item = DAL.ForumThread.FetchByID(id);
In my database my ForumPosts table looks like this:
ForumPostID | ThreadID | Description | UserID | CreatedOn| etc
So now when I have my DAL.ForumThread item I can load the connected post collection by using:
item.ForumPosts();
This all works great, but the problem is that I'm using serverside paging and want to add some additional select parameters too like showing only active records.
Is this even possible when using SubSonic 2.2 ? The workaround I have now is just creating a new SubSonic.Query and select the posts by threadid and there I can set pageindex and pagesize without problems but I think this can be done easier?
I also would like to know if it makes any difference performance wise by just using item.ForumPosts() or starting a new query, I think the forumposts are already in the ForumThreads collection and don't require a new database call right?
View 1 Replies
Jul 6, 2010
i wanna use to subsonic 3.0.4 but i dont know, how can i start to generate class and use to new Template of T4. example: create new solution for generating to table's class and add to my project. ??
View 2 Replies
Jan 4, 2011
In subsonic 2 we could do this:
public static void DeleteTable(SubSonic.TableSchema.Table table)
{
new Delete().From(table).Execute();
}
How can we do the same thing in v3? I can only seem to find documentation about using generics to target a specific table in the database...I want to be able to use it with a parameter as above.
View 2 Replies
Jul 8, 2010
Does anyone know how I can concatenate two columns in my subsonic datasource? I want to display a first and last name in this dropdownlist but I don't want to put them in the same SQL column.
View 2 Replies
Feb 8, 2011
Using a SubSonic (2.2) SqlQuery object, I am querying a view that contains distinct rows from another table. The results of the query, however, contain multiple rows for certain rows in the view. It appears to be because of a join on a temporary table in the query generated to achieve paging. How can I avoid this duplication of rows?
Bonus points: I have to use the view because SubSonic can't do .Paged() and .Distinct() at the same time. Why not?
View 1 Replies
Jun 8, 2010
I have the following code but when i try and create a new IQuerable i get an error that the interface cannot be implemented, if i take away the new i get a not implemented exception, have had to jump back and work on some old ASP classic sites for past month and for the life of me i can not wake my brain up into C# mode. The code is to create a list of priceItems, but instead of a categoryID (int) i am going to be showing the name as string.
public ActionResult ViewPriceItems(int? page)
{
var crm = 0;
page = GetPage(page);
// try and create items2
IQueryable<ViewPriceItemsModel> items2 = new IQueryable<ViewPriceItemsModel>();
// the data to be paged,but unmodified
var olditems = PriceItem.All().OrderBy(x => x.PriceItemID);
foreach (var item in olditems)
{
// set category as the name not the ID for easier reading
items2.Concat(new [] {new ViewPriceItemsModel {ID = item.PriceItemID,
Name = item.PriceItem_Name,
Category = PriceCategory.SingleOrDefault(
x => x.PriceCategoryID == item.PriceItem_PriceCategory_ID).PriceCategory_Name,
Display = item.PriceItems_DisplayMethod}});
}
crm = olditems.Count() / MaxResultsPerPage;
ViewData["numtpages"] = crm;
ViewData["curtpage"] = page + 1;
// return a paged result set
return View(new PagedList<ViewPriceItemsModel>(items2, page ?? 0, MaxResultsPerPage));
}
View 2 Replies
Nov 7, 2010
public void Add(IDataProvider provider){
var key=KeyValue();
if(key==null){
var newKey=_repo.Add(this,provider);
this.SetKeyValue(newKey);
}else{
_repo.Add(this,provider); //NullReferenceException was unhandled by user code
[Code]....
View 1 Replies
Feb 14, 2011
I'm working against a database that wasn't designed by me and in all the tables there is a CreatedBy field that is an int. Now when I generate against this db i get all kinds of errors because subsonic is expecting that field to be a varchar.
I don't particularly want to go and rename the field in all of these tables so I was hoping there was a way to "alter" or change the internal convention (without getting into the source) in subsonic.
Has anyone been able/done this in subsonic 3.0.4??
EDIT: I'm using the active record model in subsonic 3
View 6 Replies
Oct 21, 2015
I used this article Insert (Update) Data to Database with jQuery AJAX and WebMethod in ASP.Net. I want create class for this code:
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="http://cdn.jsdelivr.net/json2/0.1/json2.js"></script>
<script type="text/javascript">
$(function () {
$("[id*=btnSave]").bind("click", function () {
var user = {};
[Code] ...
And call class from button click.
View 1 Replies
May 7, 2010
I'm building an online system to be used by school groups. Only one school can log into the system at any one time, and from that school you'll get about 13 users. They then proceed into a educational application in which they have to co-operate to complete tasks, and from a code point of view, sharing variables all over the place.
I was thinking, if I set up a static class with static properties that hold the variables that are required to be shared, this could save me having to store/access the variables in/from a database, as long as the static variables are all properly initialized when the application starts and cleaned up at the end. Of course I would also have to put locks on the get and set methods to make the variables thread safe.
Something in the back of my mind is telling me this might be a terrible way of going about things, but I'm not sure exactly why, so if people could give me their thoughts for or against using a static class in this situation,
View 1 Replies
Dec 12, 2010
I make use of validation with data annotations in my model classes. How do I make sure this annotations are not violated when I validate data in my business layer, before sending it to the DAL? I guess I don't want to define the validation rules in two places (model classes and in my BLL-classes)?
View 6 Replies
Feb 17, 2011
We're converting from ColdFusion to ASP.NET 4.0 and we just don't know which route to take with setting up our classes.
In college I was taught to break everything up into separate Data Access Classes and Entity Classes that speak to the DAC. To me, that's the best option for a team that needs a lot of control over their classes and needs to reuse multiple items.
Then there is LINQ... Sure.. It's great and fast! I have no problems writing my own queries though. To me, it's not something I really need.
I would think we should be using folders that contain our DAClasses and folders that contain our Entity Classes. Then we would have our actual .aspx presentation pages.
View 1 Replies