LINQ To SQL Defining Where Class Depending On Parameters?
Jan 26, 2010[code]....
I am going to return an Object depending on the Class and Year params. I want to remove the where condition when the Class and Year parames are null or zero.
[code]....
I am going to return an Object depending on the Class and Year params. I want to remove the where condition when the Class and Year parames are null or zero.
I need to defining the Series parameters for an MS Chart.
Using the sample data below is it possible to set the X & Y value types for a graph with all days for the month on the X axis and the total number of visits for each day on the Y. Are MS Charts capable of auto generating the X axis based on the extents of the data dates as well a counting the daily instances?
[code]....
Is it possible to select on page load or page pre load a different master page depending on a number of parameters?
A simple example would be if the device is mobile, use master page A, otherwise use master page b.
Can this be done?
I have asp:Table with number of asp:Label inside asp:FormView, it represents short stats info.I need to set Label.CssClass to "red" if it's text isn't "0".Currently I do this on FormView.DataBound event. But think that it's better to use JavaScript and probably jQuery. How can I do that?
View 1 RepliesI need to make a webservice in .net (I know how this works) but then I need to get data out of a database. But my company wants to make it in a way that you can use the system with multiple databases.
So my option was make multiple abstract classes which contains the folowing code (depending on the database type, this would be a SQL database)
public abstract class AbstractDAO<T, Tid>
Using routing in web forms in ASP.NET 4.0. Looking to use dynamic parameters in the RoutingExpressionBuilder class something like:
NavigateUrl="<%$ RouteUrl:searchterm={dynamicParameterFromObject} %>">
Would like to know the proper syntax is available.
I am working on LINQ. I am calling a SQL Stored Procedure with 2-3 parameters it's working fine. When i am going to call Stored Procedure with 8 to 9 parameters the auto generated column is not comming automatically. So i am unable to use LINQ with Stored Procedure with multiple parameters.
View 4 RepliesI have a linqdatasource and I want to use an enum for Type as below:
<asp:linqdatasource id="GridDataSource" runat="server" enabledelete="true" Where="Type == @Type">
<whereparameters>
<asp:dynamiccontrolparameter controlid="FilterRepeater" />
<asp:QueryStringParameter QueryStringField="Type" Name="Type" ConvertEmptyStringToNull="false" />
</whereparameters>
</asp:linqdatasource>
It keeps throwing an error:
Operator '==' incompatible with operand types 'ProductType' and 'String' ProductType is my Enum, and String is my input type. I don't seem to be able to convert one to the other.
I am using LINQ-to-Entities and here is my query
public void SomeFunction(string searchField)
{
var data = from a in dx.SomeTable where [code]...
Now if I had to use the value of the parameter "searchField" as the property to be selected in the where clause then how do I do it ?
i.e I want to assign the value of the parameter "searchField" to the property I am checking in the where clause.
So ... the value of "SomeProperty" in a.SomeProperty must be the value of "searchField". How to do this ?
PS : I dont want a.SomeProperty=searchField. What I want is "SomeProperty" itself to be replaced by the value of "searchField" and then , this has to be checked to see if its equal to 270.
I just struck upon a prime opportunity to further exhibit my MVC ignorance, by way of the following: How can one make use of a custom view model class that has parameters in the constructor? For example, a class that could intitialize various collections/properties based on an IPrincipal object passed in. I've come across several allusions to this scenario, involving a class inheriting DefaultModelBinder which overrides the CreateModel method, but have yet to find an example.
[Code]....
I've got a Linq datasource hitched up to a Formview control for clients to edit some data. I'm having trouble setting the where parameters withing the control so it show the right set of data. Here's the markup:
[Code]....
Upon running right now, it's completely ignoring the where parameters. What am I missing here?
im new to linq and im having lots of trouble creating complex queries.. My problem mainly is that i am using Linq as a BLL.
i created a dbml (with namespace called DAL) file with 2 tables with a one to many relation. Pop and City. There is a forgien key in pop that points to a city. I also created a class called Pop that inhertis DAL.Pop. Now in my ASPX page, i want to call a function in the Pop class that would retrieve some Pop according to its ID, but i need the city name as well.. Ive been going around this in circles for days. I dont know how to write the Linq syntax and i dont understandd how my function's signature should be like.. I want to recieve a table that i can bind to a Gridview and preferable, specify which coloumns to bind.
I am new to LINQ to XML in .net(C#, asp.net). I want to know more about Lambda expressions. I am using Lambada expression with the following query.
count = FieldRoot.Element("USER").Element("MM")
.Descendants("MMMS")
.Where(a => a.Attribute("ID").Value == MID)
.SelectMany(b => b.Descendants("ABC")).Count();
how the Lambda expression work specially in case of parameters (in the above case a & b) ? What is the basic concept of parameters in Lambda expression ? Can we use the names of the variables defined outside of the query instead of a & b ? which elements a & b represent in the above case represent ? Can we pass parameters from outside in the query ? If we can pass parameters from outside query then how it will be done? If you give me any other example instead of the above query to understand the concept of parameter in Lambda expression.
I have an ObjectDataSource3 that I am trying to use to insert data from:
From: Dropdownlist1.selected value To: (CustomerID)
From: Dropdownlist2.selected value To: (ProductCode)
From: txtTitle (Title) To: (Title)
CurrentDate To: DateOpened
The btnAdd event is suppose to calls:
ObjectDataSource3.Insert()
Below is my code for both the page and class. Although my class is expecting parameters, I don't know how to get the parameters to the insert function in my class.
[Code]....
[Code]....
I have a stored procedure with the following structure:
[Code]....
Using the properties as defined in a class, how about can I put them into the ParamArray parameters argument of my function. The code as follows:
Public Class MyObject
Public Property Prop1 as string
Public Property Prop2 as integer
Public Property Prop3 as Boolean
Public Sub AddNewMyObject
MsSQL_ExecuteNonQuery("StoredProc_AddNewMyObject", ________________?)
End Sub
End Class
Protected Function MsSQL_ExecuteNonQuery(ByVal storedProc as string, ByVal ParamArray parameters as object())
'Some Code here.
End Function
I have a businessprojects.cs in this project i am using linqtosql.dbml ... i am not able to create an instance for the linq
how to do this...
I have below class and function. Could I use LINQ to select from class list?? What the syntax should be??
class ItemsPromo
{
public long itemID;
public long promotionID;[code]....
i want create a class Library work with SQL Linq ,when i create a LINQ Data Class it automatic create some connectionString and use the database namemy question is can i change some settings that, use this class Library in difrent website with difrent connectionStrings?
View 6 Repliesi have my page who load my gridview as: GRW.datasource=className.List2(2);i have this function in my class
[Code]....
it returns an error , cannot convert single result to queryable!! in " blo= DB.MarketList(TypeID);"
i use GUI tool of vs2008 to generate some LINQ to SQL class, my problem is StringTemplate can not reach attributes of those model
$persons:{
<li>$it.name$</li>
}$
it printed:
<li></li>
<li></li>
<li></li>
name is public property of Person model. If i create a person class by myself, and the same attributes, StringTemplate can get it.
I have a class object which is basically kind of hierarchy and looks like this when I convert that to XML.
[Code]....
So you can see that I have "objectComponent" which is kind of hierarchy and that hierarchy can be upto any level.
Now I need to update <quantity> value where <sku> = "SKU 2", remember this <sku> can be anywhere in hierarchy, so I need to update its <quantity> value where <sku> = "SKU 2".
So my question is how can I update that value using Linq query and specifically, I need that value to be updated in the actual object itself because I need to pass that updated object for furthur process.
In my c# code, there is only one class named "ObjectComponent" and that has all of these properties and "objectBundle" as array and the whole hierarchy starts from there.
how can I update value in this object directly?
I want to write the Customer belongs their product
Customer 1 and their details
then products details Purchased by Customer 1
Customer 2 and their details
then products details Purchased by Customer 2
public class Customer {
public int CustID { get; set; }
public string CustName { get; set; }
public string CustEmail { get; set; }
public string CustContact { get; set; }
public string CustAdd { get; set; }
[Code] .....
I tried to add a custom property to the data model:
public partial class Department
{
public string ExtensionIdName
{
get
{
return Extension.ExtensionName;
}
set
{
}
}
}
It seems that it works, but when I bind the data to a ListView it shows all the properties except the property I added manualy (ExtensionIdName).
For some unknown reason I suddenly am unable to create an object variable for a Linq Data Class. If I create a new project and try the process again with the same database everything works as advertized.The code I am using is Dim db As New RoggDataContext which gives me an error on the object variable "db": Overload resolution failed because no accessibility 'NEW' accepts this number of arguments.I have looked inside every file in the Web Project like the web config to check the connection string, gobal, and designer.vb looking for any errors whit no JOY. I also tried to create a new form and code behind with a button and received the same error.This is mind blowing because as I already stated, I can create a new Web Site and the problem goes away.
View 3 Replies