Search Results

Search found 1285 results on 52 pages for 'csharp noob'.

Page 13/52 | < Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >

  • Dynamic LINQ in an Assembly Near By

    - by Ricardo Peres
    You may recall my post on Dynamic LINQ. I said then that you had to download Microsoft's samples and compile the DynamicQuery project (or just grab my copy), but there's another way. It turns out Microsoft included the Dynamic LINQ classes in the System.Web.Extensions assembly, not the one from ASP.NET 2.0, but the one that was included with ASP.NET 3.5! The only problem is that all types are private: Here's how to use it: Assembly asm = typeof(UpdatePanel).Assembly; Type dynamicExpressionType = asm.GetType("System.Web.Query.Dynamic.DynamicExpression"); MethodInfo parseLambdaMethod = dynamicExpressionType.GetMethods(BindingFlags.Public | BindingFlags.Static).Where(m = (m.Name == "ParseLambda") && (m.GetParameters().Length == 2)).Single().MakeGenericMethod(typeof(DateTime), typeof(Boolean)); Func filterExpression = (parseLambdaMethod.Invoke(null, new Object [] { "Year == 2010", new Object [ 0 ] }) as Expression).Compile(); List list = new List { new DateTime(2010, 1, 1), new DateTime(1999, 1, 12), new DateTime(1900, 10, 10), new DateTime(1900, 2, 20), new DateTime(2012, 5, 5), new DateTime(2012, 1, 20) }; IEnumerable filteredDates = list.Where(filterExpression); SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.all();

    Read the article

  • VS2012 - How to manually convert .NET Class Library to a Portable Class Library

    - by Igor Milovanovic
    The portable libraries are the  response to the growing profile fragmentation in .NET frameworks. With help of portable libraries you can share code between different runtimes without dreadful #ifdef PLATFORM statements or even worse “Add as Link” source file sharing practices. If you have an existing .net class library which you would like to reference from a different runtime (e.g. you have a .NET Framework 4.5 library which you would like to reference from a Windows Store project), you can either create a new portable class library and move the classes there or edit the existing .csproj file and change the XML directly. The following example shows how to convert a .NET Framework 4.5 library to a Portable Class Library. First Unload the Project and change the following settings in the .csproj file: <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> to: <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable \$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" /> and add the following keys to the first property group in order to get visual studio to show the framework picker dialog: <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB}; {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>   After that you can select the frameworks in the Library Tab of the Portable Library:   As last step, delete any framework references from the library as you have them already referenced via the .NET Portable Subset.     [1] Cross-Platform Development with the .NET Framework - http://msdn.microsoft.com/en-us/library/gg597391.aspx [2] Framework Profiles in .NET: http://nitoprograms.blogspot.de/2012/05/framework-profiles-in-net.html

    Read the article

  • Yet Another Way To Create An Object

    - by Ricardo Peres
    After I wrote this post, I come up with yet another way to create an object... Here it is: Stopwatch watch = new Stopwatch(); ConstructorInfo ci = typeof(StringBuilder).GetConstructor(new Type[0]); NewExpression expr = Expression.New(ci); Func<StringBuilder> func = Expression.Lambda(typeof(Func<StringBuilder>), expr).Compile() as Func<StringBuilder>; watch.Start(); for (Int32 i = 0; i < 100; ++i) { StringBuilder builder = func(); } Int64 time4 = watch.ElapsedTicks; watch.Reset(); I know of only one other way, which is by using CodeDOM. If you know of any other ways to create an object, let me know! SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.all();

    Read the article

  • Creating a Sandboxed Instance

    - by Ricardo Peres
    In .NET 4.0 the policy APIs have changed a bit. Here's how you can create a sandboxed instance of a type, which must inherit from MarshalByRefObject: static T CreateRestrictedType<T>(SecurityZone zone, params Assembly [] fullTrustAssemblies) where T : MarshalByRefObject, new() { return(CreateRestrictedType<T>(zone, fullTrustAssemblies, new IPermission [0]); } static T CreateRestrictedType<T>(SecurityZone zone, params IPermission [] additionalPermissions) where T : MarshalByRefObject, new() { return(CreateRestrictedType<T>(zone, new Assembly [0], additionalPermissions); } static T CreateRestrictedType<T>(SecurityZone zone, Assembly [] fullTrustAssemblies, IPermission [] additionalPermissions) where T : MarshalByRefObject, new() { Evidence evidence = new Evidence(); evidence.AddHostEvidence(new Zone(zone)); PermissionSet evidencePermissionSet = SecurityManager.GetStandardSandbox(evidence); foreach (IPermission permission in additionalPermissions ?? new IPermission[ 0 ]) { evidencePermissionSet.AddPermission(permission); } StrongName [] strongNames = (fullTrustAssemblies ?? new Assembly[0]).Select(a = a.Evidence.GetHostEvidence<StrongName>()).ToArray(); AppDomainSetup adSetup = new AppDomainSetup(); adSetup.ApplicationBase = Path.GetDirectoryName(typeof(T).Assembly.Location); AppDomain newDomain = AppDomain.CreateDomain("Sandbox", evidence, adSetup, evidencePermissionSet, strongNames); ObjectHandle handle = Activator.CreateInstanceFrom(newDomain, typeof(T).Assembly.ManifestModule.FullyQualifiedName, typeof(T).FullName); return (handle.Unwrap() as T); } SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.all();

    Read the article

  • How to translate along Z axis in OpenTK

    - by JeremyJAlpha
    I am playing around with an OpenGL sample application I downloaded for Xamarin-Android. The sample application produces a rotating colored cube I would simply like to edit it so that the rotating cube is translated along the Z axis and disappears into the distance. I modified the code by: adding an cumulative variable to store my Z distance, adding GL.Enable(All.DepthBufferBit) - unsure if I put it in the right place, adding GL.Translate(0.0f, 0.0f, Depth) - before the rotate functions, Result: cube rotates a couple of times then disappears, it seems to be getting clipped out of the frustum. So my question is what is the correct way to use and initialize the Z buffer and get the cube to travel along the Z axis? I am sure I am missing some function calls but am unsure of what they are and where to put them. I apologise in advance as this is very basic stuff but am still learning :P, I would appreciate it if anyone could show me the best way to get the cube to still rotate but to also move along the Z axis. I have commented all my modifications in the code: // This gets called when the drawing surface is ready protected override void OnLoad (EventArgs e) { // this call is optional, and meant to raise delegates // in case any are registered base.OnLoad (e); // UpdateFrame and RenderFrame are called // by the render loop. This is takes effect // when we use 'Run ()', like below UpdateFrame += delegate (object sender, FrameEventArgs args) { // Rotate at a constant speed for (int i = 0; i < 3; i ++) rot [i] += (float) (rateOfRotationPS [i] * args.Time); }; RenderFrame += delegate { RenderCube (); }; GL.Enable(All.DepthBufferBit); //Added by Noob GL.Enable(All.CullFace); GL.ShadeModel(All.Smooth); GL.Hint(All.PerspectiveCorrectionHint, All.Nicest); // Run the render loop Run (30); } void RenderCube () { GL.Viewport(0, 0, viewportWidth, viewportHeight); GL.MatrixMode (All.Projection); GL.LoadIdentity (); if ( viewportWidth > viewportHeight ) { GL.Ortho(-1.5f, 1.5f, 1.0f, -1.0f, -1.0f, 1.0f); } else { GL.Ortho(-1.0f, 1.0f, -1.5f, 1.5f, -1.0f, 1.0f); } GL.MatrixMode (All.Modelview); GL.LoadIdentity (); Depth -= 0.02f; //Added by Noob GL.Translate(0.0f,0.0f,Depth); //Added by Noob GL.Rotate (rot[0], 1.0f, 0.0f, 0.0f); GL.Rotate (rot[1], 0.0f, 1.0f, 0.0f); GL.Rotate (rot[2], 0.0f, 1.0f, 0.0f); GL.ClearColor (0, 0, 0, 1.0f); GL.Clear (ClearBufferMask.ColorBufferBit); GL.VertexPointer(3, All.Float, 0, cube); GL.EnableClientState (All.VertexArray); GL.ColorPointer (4, All.Float, 0, cubeColors); GL.EnableClientState (All.ColorArray); GL.DrawElements(All.Triangles, 36, All.UnsignedByte, triangles); SwapBuffers (); }

    Read the article

  • Convert your Hash keys to object properties in Ruby

    - by kerry
    Being a Ruby noob (and having a background in Groovy), I was a little surprised that you can not access hash objects using the dot notation.  I am writing an application that relies heavily on XML and JSON data.  This data will need to be displayed and I would rather use book.author.first_name over book[‘author’][‘first_name’].  A quick search on google yielded this post on the subject. So, taking the DRYOO (Don’t Repeat Yourself Or Others) concept.  I came up with this: 1: class ::Hash 2:  3: # add keys to hash 4: def to_obj 5: self.each do |k,v| 6: if v.kind_of? Hash 7: v.to_obj 8: end 9: k=k.gsub(/\.|\s|-|\/|\'/, '_').downcase.to_sym 10: self.instance_variable_set("@#{k}", v) ## create and initialize an instance variable for this key/value pair 11: self.class.send(:define_method, k, proc{self.instance_variable_get("@#{k}")}) ## create the getter that returns the instance variable 12: self.class.send(:define_method, "#{k}=", proc{|v| self.instance_variable_set("@#{k}", v)}) ## create the setter that sets the instance variable 13: end 14: return self 15: end 16: end This works pretty well.  It converts each of your keys to properties of the Hash.  However, it doesn’t sit very well with me because I probably will not use 90% of the properties most of the time.  Why should I go through the performance overhead of creating instance variables for all of the unused ones? Enter the ‘magic method’ #missing_method: 1: class ::Hash 2: def method_missing(name) 3: return self[name] if key? name 4: self.each { |k,v| return v if k.to_s.to_sym == name } 5: super.method_missing name 6: end 7: end This is a much cleaner method for my purposes.  Quite simply, it checks to see if there is a key with the given symbol, and if not, loop through the keys and attempt to find one. I am a Ruby noob, so if there is something I am overlooking, please let me know.

    Read the article

  • Help me to set samba and apache on my Ubuntu VM from Vista, starting from ping

    - by avastreg
    Ok the title is not so clear after all, so let's start with the problem description posting some points: i'm on Win Vista i have a Virtual Box Ubuntu 9.04 server (Virtual Machine) installed in windows i'm under Active Directory (maybe helps), with network 192.168.2.x After Ubuntu installation (LAMP), i have: Ubuntu Ip set to 10.0.2.15 (dhcp) Vista pings Ubuntu and Ubuntu pings Vista (only IPs, not names) Can't connect to Apache (default install ubuntu server) at the url h**p://10.0.2.15/ On Ubuntu, testing Apache by doing 'wget http://10.0.2.15/' works Tried to setup samba, writing a share def, but nothing, i can't access from Vista to Ubuntu My scope is: Setting up samba to work on files from windows Reaching apache to test web pages Ok i'm not completely noob (but i'm on the noob way anyway) and i've tried many solutions, so please try to help me; let's look together what went wrong :)

    Read the article

  • VS2010 - Add template to New Project window

    - by gbogumil
    I am trying to add a new project template for an often used pattern. Starting from the class library template I have done the following (it still does not show up in the new project window): opened the .vstemplate file changed name and description to 'hard coded' values (my template). The values in there pulled from the csharpui.dll resources. changed the TemplateID, DefaultName, and ProjectItems included. saved these to the ProjectemplatesCache folder and as a zip in the ProjectTemplates folder. restarted VS2010 and checked the new project location which should have shown my new template. specifically, the folders I saved to were.. C:\program files\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplatesCache\CSharp\Windows\1033\HostComm.zip (the zip is the folder name, not a zip file) and C:\program files\Microsoft Visual Studio 10.0\Common7\IDE\ProjectTemplates\CSharp\Windows\1033 (this folder has a HostComm.zip file in it) Has anyone else done this? Can it be done? If it can then what did I miss?

    Read the article

  • Rewriting VB.NET Lambda experession as a C# statement

    - by ChadD
    I downgraded my app from version 4 of the framework to version 4 and now I want to implement this VB.NET lambda function statement (which works on 3.5) Dim colLambda As ColumnItemValueAccessor = Function(rowItem As Object) General_ItemValueAccessor(rowItem, colName) and rewrite it in C#. This was my attempt: ColumnItemValueAccessor colLambda = (object rowItem) => General_ItemValueAccessor(rowItem, colName); When I did this, I get the following error: Error 14 One or more types required to compile a dynamic expression cannot be found. Are you missing references to Microsoft.CSharp.dll and System.Core.dll? C:\Source\DotNet\SqlSmoke\SqlSmoke\UserControls\ScriptUserControl.cs 84 73 SqlSmoke However, when I downgraded the app from version 4.0 of the framework to 3.5 (because our users only hae 3.5 and don't have rights to install 4.0). when I did this, the reference to "Microsoft.CSharp" was broken. Can I rewrite the VB.NET command in C# using syntax that is valid in C# 3.5 as I was able to in VB.NET? What would the syntax be?

    Read the article

  • Pinvoke- to call a function with pointer to pointer to pointer parameter

    - by jambodev
    complete newbe in PInvoke. I have a function in C with this signature: int addPos(int init_array_size, int *cnt, int *array_size, PosT ***posArray, PosT ***hPtr, char *id, char *record_id, int num, char *code, char *type, char *name, char *method, char *cont1, char *cont2, char *cont_type, char *date1, char *date_day, char *date2, char *dsp, char *curr, char *contra_acc, char *np, char *ten, char *dsp2, char *covered, char *cont_subtype, char *Xcode, double strike, int version, double t_price, double long, double short, double scale, double exrcised_price, char *infoMsg); and here is how PosT looks like: typedef union pu { struct dpos d; struct epo e; struct bpos b; struct spos c; } PosT ; my questions are: 1- do I need to define a class in CSharp representing PosT? 2- how do I pass PosT ***posArray parameter across frm CSharp to C? 3- How do I specify marshaling for it all? I Do appreciate your help

    Read the article

  • MissingMethodException in C# Program

    - by draghia-aurelian
    I wrote a Windows Form Application in C# and it works well for my computer. But on another PC, an error occurs when I try to do some stuff. MenuItem_Click Event Handler private void rUNToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("I'm in rUNToolStripMenuItem_Click!"); ... } ToolStripMenuItem Event Handler private void dataPositionToolStripMenuItem_Click(object sender, EventArgs e) { MessageBox.Show("I'm in dataPositionToolStripMenuItem_Click!"); ... } Running on my computer: MenuItem_ClickEvent Handler Output (On My PC) MessageBox appears: "I'm in rUNToolStripMenuItem_Click" ToolStripMenuItem Event Handler (On My PC) MessageBox appears: "I'm in dataPositionToolStripMenuItem_Click!" MenuItem_Click Event Handler: (On another PC) Messagebox doesn't appear and an Exception is thrown Method not found: "Void Microsoft.CSharp.RuntimeBinder.CSharpGetMemberBinder.ctor( System.String.System.Type, System.Collections.Generic.IEnumerable'1<Microsoft .CSharp.RuntimeBinder.CSharpArgument Info>)'. This is the PrintScreen with error: What am I doing wrong?

    Read the article

  • Why its not working?

    - by Andrew Hoffmann
    BinaryReader br = new BinaryReader(Console.OpenStandardInput()); BinaryWriter bw = new BinaryWriter(Console.OpenStandardOutput()); int n = br.ReadInt32(); bw.Write(n); always getting this error: Unhandled Exception: System.IO.EndOfStreamException: Failed to read past end of stream. at System.IO.BinaryReader.FillBuffer (Int32 numBytes) [0x00000] in <filename unknown>:0 at System.IO.BinaryReader.ReadInt32 () [0x00000] in <filename unknown>:0 at Program.Main () [0x00025] in /home/skydos/ACM/Csharp/Csharp/Main.cs:24 Is there any way to make reading data in C# faster from Console?

    Read the article

  • Problem with compiler in Web.Config for generating xml doc

    - by asksuperuser
    I have several problems when putting code below in Web.Config to be able to generate xml doc with website (not webproject): <compiler language="c#;cs;csharp" extension=".cs" warningLevel="0" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" compilerOptions="/doc:c:\doc\WebDocs.xml"> How do I put a directory with spaces instead of /doc:c:\doc\WebDocs.xml? How do I put a directory that is a subdirectory of current project? Why my xml file output is nearly empty? Is it because some properties, methods, ... have no xml comment?

    Read the article

  • How to open an Excel file in C#?

    - by tksy
    I am trying to convert some VBA code to C#. I am new to C#. Currently I am trying to open an Excel file from a folder and if it does not exist then create it. I am trying something like the following. How can I make it work? Excel.Application objexcel; Excel.Workbook wbexcel; bool wbexists; Excel.Worksheet objsht; Excel.Range objrange; objexcel = new Excel.Application(); if (Directory("C:\\csharp\\error report1.xls") = "") { wbexcel.NewSheet(); } else { wbexcel.Open("C:\\csharp\\error report1.xls"); objsht = ("sheet1"); } objsht.Activate();

    Read the article

  • Dynamic Paging and Sorting

    - by Ricardo Peres
    Since .NET 3.5 brought us LINQ and expressions, I became a great fan of these technologies. There are times, however, when strong typing cannot be used - for example, when you are developing an ObjectDataSource and you need to do paging having just a column name, a page index and a page size, so I set out to fix this. Yes, I know about Dynamic LINQ, and even talked on it previously, but there's no need to add this extra assembly. So, without further delay, here's the code, in both generic and non-generic versions: public static IList ApplyPagingAndSorting(IEnumerable enumerable, Type elementType, Int32 pageSize, Int32 pageIndex, params String [] orderByColumns) { MethodInfo asQueryableMethod = typeof(Queryable).GetMethods(BindingFlags.Static | BindingFlags.Public).Where(m = (m.Name == "AsQueryable") && (m.ContainsGenericParameters == false)).Single(); IQueryable query = (enumerable is IQueryable) ? (enumerable as IQueryable) : asQueryableMethod.Invoke(null, new Object [] { enumerable }) as IQueryable; if ((orderByColumns != null) && (orderByColumns.Length 0)) { PropertyInfo orderByProperty = elementType.GetProperty(orderByColumns [ 0 ]); MemberExpression member = Expression.MakeMemberAccess(Expression.Parameter(elementType, "n"), orderByProperty); LambdaExpression orderBy = Expression.Lambda(member, member.Expression as ParameterExpression); MethodInfo orderByMethod = typeof(Queryable).GetMethods(BindingFlags.Public | BindingFlags.Static).Where(m = m.Name == "OrderBy").ToArray() [ 0 ].MakeGenericMethod(elementType, orderByProperty.PropertyType); query = orderByMethod.Invoke(null, new Object [] { query, orderBy }) as IQueryable; if (orderByColumns.Length 1) { MethodInfo thenByMethod = typeof(Queryable).GetMethods(BindingFlags.Public | BindingFlags.Static).Where(m = m.Name == "ThenBy").ToArray() [ 0 ].MakeGenericMethod(elementType, orderByProperty.PropertyType); PropertyInfo thenByProperty = null; MemberExpression thenByMember = null; LambdaExpression thenBy = null; for (Int32 i = 1; i 0) { MethodInfo takeMethod = typeof(Queryable).GetMethod("Take", BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(elementType); MethodInfo skipMethod = typeof(Queryable).GetMethod("Skip", BindingFlags.Public | BindingFlags.Static).MakeGenericMethod(elementType); query = skipMethod.Invoke(null, new Object [] { query, pageSize * pageIndex }) as IQueryable; query = takeMethod.Invoke(null, new Object [] { query, pageSize }) as IQueryable; } MethodInfo toListMethod = typeof(Enumerable).GetMethod("ToList", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(elementType); IList list = toListMethod.Invoke(null, new Object [] { query }) as IList; return (list); } public static List ApplyPagingAndSorting(IEnumerable enumerable, Int32 pageSize, Int32 pageIndex, params String [] orderByColumns) { return (ApplyPagingAndSorting(enumerable, typeof(T), pageSize, pageIndex, orderByColumns) as List); } List list = new List { new DateTime(2010, 1, 1), new DateTime(1999, 1, 12), new DateTime(1900, 10, 10), new DateTime(1900, 2, 20), new DateTime(2012, 5, 5), new DateTime(2012, 1, 20) }; List sortedList = ApplyPagingAndSorting(list, 3, 0, "Year", "Month", "Day"); SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.all();

    Read the article

  • Linq Tutorial

    - by SAMIR BHOGAYTA
    Microsoft LINQ Tutorials http://www.deitel.com/ResourceCenters/Programming/MicrosoftLINQ/Tutorials/tabid/2673/Default.aspx Introducing C# 3 – Part 4 LINQ http://www.programmersheaven.com/2/CSharp3-4 101 LINQ Samples http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx What is LinQ http://www.dotnetspider.com/forum/173039-what-linq-net.aspx Beginners Guides http://www.progtalk.com/viewarticle.aspx?articleid=68 http://www.programmersheaven.com/2/CSharp3-4 http://dotnetslackers.com/articles/csharp/introducinglinq1.aspx Using Linq http://weblogs.asp.net/scottgu/archive/2006/05/14/446412.aspx Step By Step Articles http://www.codeproject.com/KB/linq/linqtutorial.aspx http://www.codeproject.com/KB/linq/linqtutorial2.aspx http://www.codeproject.com/KB/linq/linqtutorial3.aspx

    Read the article

  • Change Tracking

    - by Ricardo Peres
    You may recall my last post on Change Data Control. This time I am going to talk about other option for tracking changes to tables on SQL Server: Change Tracking. The main differences between the two are: Change Tracking works with SQL Server 2008 Express Change Tracking does not require SQL Server Agent to be running Change Tracking does not keep the old values in case of an UPDATE or DELETE Change Data Capture uses an asynchronous process, so there is no overhead on each operation Change Data Capture requires more storage and processing Here's some code that illustrates it's usage: -- for demonstrative purposes, table Post of database Blog only contains two columns, PostId and Title -- enable change tracking for database Blog, for 2 days ALTER DATABASE Blog SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS, AUTO_CLEANUP = ON); -- enable change tracking for table Post ALTER TABLE Post ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = ON); -- see current records on table Post SELECT * FROM Post SELECT * FROM sys.sysobjects WHERE name = 'Post' SELECT * FROM sys.sysdatabases WHERE name = 'Blog' -- confirm that table Post and database Blog are being change tracked SELECT * FROM sys.change_tracking_tables SELECT * FROM sys.change_tracking_databases -- see current version for table Post SELECT p.PostId, p.Title, c.SYS_CHANGE_VERSION, c.SYS_CHANGE_CONTEXT FROM Post AS p CROSS APPLY CHANGETABLE(VERSION Post, (PostId), (p.PostId)) AS c; -- update post UPDATE Post SET Title = 'First Post Title Changed' WHERE Title = 'First Post Title'; -- see current version for table Post SELECT p.PostId, p.Title, c.SYS_CHANGE_VERSION, c.SYS_CHANGE_CONTEXT FROM Post AS p CROSS APPLY CHANGETABLE(VERSION Post, (PostId), (p.PostId)) AS c; -- see changes since version 0 (initial) SELECT p.Title, c.PostId, SYS_CHANGE_VERSION, SYS_CHANGE_OPERATION, SYS_CHANGE_COLUMNS, SYS_CHANGE_CONTEXT FROM CHANGETABLE(CHANGES Post, 0) AS c LEFT OUTER JOIN Post AS p ON p.PostId = c.PostId; -- is column Title of table Post changed since version 0? SELECT CHANGE_TRACKING_IS_COLUMN_IN_MASK(COLUMNPROPERTY(OBJECT_ID('Post'), 'Title', 'ColumnId'), (SELECT SYS_CHANGE_COLUMNS FROM CHANGETABLE(CHANGES Post, 0) AS c)) -- get current version SELECT CHANGE_TRACKING_CURRENT_VERSION() -- disable change tracking for table Post ALTER TABLE Post DISABLE CHANGE_TRACKING; -- disable change tracking for database Blog ALTER DATABASE Blog SET CHANGE_TRACKING = OFF; You can read about the differences between the two options here. Choose the one that best suits your needs! SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.brushes.Xml.aliases = ['xml']; SyntaxHighlighter.all();

    Read the article

  • Trouble compiling MonoDevelop 4 on Ubuntu 12.04

    - by Mehran
    I'm trying to compile the latest version of MonoDevelop (4.0.9) on my Ubuntu 12.04 and I'm facing errors I can not overcome. Here are my machine's configurations: OS: Ubuntu 12.04 64-bit Mono: version 3.0.12 And here are the commands that I ran to download MonoDevelop: $ git clone git://github.com/mono/monodevelop.git $ cd monodevelop $ git submodule init $ git submodule update And afterwards to compile: ./configure --prefix=`pkg-config --variable=prefix mono` --profile=stable make Then I faced the following errors (sorry if it's long): ... Building ./Main.sln xbuild /verbosity:quiet /nologo /property:CodePage=65001 ./Main.sln /property:Configuration=Debug /home/mehran/git/monodevelop/main/Main.sln: warning : Don't know how to handle GlobalSection MonoDevelopProperties.Debug, Ignoring. : warning CS1685: The predefined type `System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies. Using definition from `mscorlib' /usr/lib/mono/4.0/Microsoft.CSharp.targets: error : Compiler crashed with code: 1. : warning CS1685: The predefined type `System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies. Using definition from `mscorlib' Editor/IDocument.cs(98,30): warning CS0419: Ambiguous reference in cref attribute `GetOffset'. Assuming `ICSharpCode.NRefactory.Editor.IDocument.GetOffset(int, int)' but other overloads including `ICSharpCode.NRefactory.Editor.IDocument.GetOffset(ICSharpCode.NRefactory.TextLocation)' have also matched PatternMatching/INode.cs(51,37): warning CS1574: XML comment on `ICSharpCode.NRefactory.PatternMatching.PatternExtensions.Match(this ICSharpCode.NRefactory.PatternMatching.INode, ICSharpCode.NRefactory.PatternMatching.INode)' has cref attribute `PatternMatching.Match.Success' that could not be resolved TextLocation.cs(35,23): warning CS0419: Ambiguous reference in cref attribute `Editor.IDocument.GetOffset'. Assuming `ICSharpCode.NRefactory.Editor.IDocument.GetOffset(int, int)' but other overloads including `ICSharpCode.NRefactory.Editor.IDocument.GetOffset(ICSharpCode.NRefactory.TextLocation)' have also matched TypeSystem/FullTypeName.cs(87,24): warning CS0419: Ambiguous reference in cref attribute `ReflectionHelper.ParseReflectionName'. Assuming `ICSharpCode.NRefactory.TypeSystem.ReflectionHelper.ParseReflectionName(string)' but other overloads including `ICSharpCode.NRefactory.TypeSystem.ReflectionHelper.ParseReflectionName(string, ref int)' have also matched TypeSystem/INamedElement.cs(59,24): warning CS0419: Ambiguous reference in cref attribute `ReflectionHelper.ParseReflectionName'. Assuming `ICSharpCode.NRefactory.TypeSystem.ReflectionHelper.ParseReflectionName(string)' but other overloads including `ICSharpCode.NRefactory.TypeSystem.ReflectionHelper.ParseReflectionName(string, ref int)' have also matched TypeSystem/IType.cs(50,26): warning CS1584: XML comment on `ICSharpCode.NRefactory.TypeSystem.IType' has syntactically incorrect cref attribute `IEquatable{IType}.Equals(IType)' TypeSystem/IType.cs(319,38): warning CS1580: Invalid type for parameter `1' in XML comment cref attribute `GetMethods(Predicate{IUnresolvedMethod}, GetMemberOptions)' TypeSystem/TypeKind.cs(61,17): warning CS1580: Invalid type for parameter `1' in XML comment cref attribute `IType.GetNestedTypes(Predicate{ITypeDefinition}, GetMemberOptions)' TypeSystem/SpecialType.cs(50,52): warning CS1580: Invalid type for parameter `1' in XML comment cref attribute `IType.GetNestedTypes(Predicate{ITypeDefinition}, GetMemberOptions)' /usr/lib/mono/4.0/Microsoft.CSharp.targets: error : Compiler crashed with code: 1.

    Read the article

  • Dynamic Filtering

    - by Ricardo Peres
    Continuing my previous posts on dynamic LINQ, now it's time for dynamic filtering. For now, I'll focus on string matching. There are three standard operators for string matching, which both NHibernate, Entity Framework and LINQ to SQL recognize: Equals Contains StartsWith EndsWith So, if we want to apply filtering by one of these operators on a string property, we can use this code: public enum MatchType { StartsWith = 0, EndsWith = 1, Contains = 2, Equals = 3 } public static List Filter(IEnumerable enumerable, String propertyName, String filter, MatchType matchType) { return (Filter(enumerable, typeof(T), propertyName, filter, matchType) as List); } public static IList Filter(IEnumerable enumerable, Type elementType, String propertyName, String filter, MatchType matchType) { MethodInfo asQueryableMethod = typeof(Queryable).GetMethods(BindingFlags.Static | BindingFlags.Public).Where(m = (m.Name == "AsQueryable") && (m.ContainsGenericParameters == false)).Single(); IQueryable query = (enumerable is IQueryable) ? (enumerable as IQueryable) : asQueryableMethod.Invoke(null, new Object [] { enumerable }) as IQueryable; MethodInfo whereMethod = typeof(Queryable).GetMethods(BindingFlags.Public | BindingFlags.Static).Where(m = m.Name == "Where").ToArray() [ 0 ].MakeGenericMethod(elementType); MethodInfo matchMethod = typeof(String).GetMethod ( (matchType == MatchType.StartsWith) ? "StartsWith" : (matchType == MatchType.EndsWith) ? "EndsWith" : (matchType == MatchType.Contains) ? "Contains" : "Equals", new Type [] { typeof(String) } ); PropertyInfo displayProperty = elementType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.Instance); MemberExpression member = Expression.MakeMemberAccess(Expression.Parameter(elementType, "n"), displayProperty); MethodCallExpression call = Expression.Call(member, matchMethod, Expression.Constant(filter)); LambdaExpression where = Expression.Lambda(call, member.Expression as ParameterExpression); query = whereMethod.Invoke(null, new Object [] { query, where }) as IQueryable; MethodInfo toListMethod = typeof(Enumerable).GetMethod("ToList", BindingFlags.Static | BindingFlags.Public).MakeGenericMethod(elementType); IList list = toListMethod.Invoke(null, new Object [] { query }) as IList; return (list); } var list = new [] { new { A = "aa" }, new { A = "aabb" }, new { A = "ccaa" }, new { A = "ddaadd" } }; var contains = Filter(list, "A", "aa", MatchType.Contains); var endsWith = Filter(list, "A", "aa", MatchType.EndsWith); var startsWith = Filter(list, "A", "aa", MatchType.StartsWith); var equals = Filter(list, "A", "aa", MatchType.Equals); Perhaps I'll write some more posts on this subject in the near future. SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.all();

    Read the article

  • Lesser Known NHibernate Session Methods

    - by Ricardo Peres
    The NHibernate ISession, the core of NHibernate usage, has some methods which are quite misunderstood and underused, to name a few, Merge, Persist, Replicate and SaveOrUpdateCopy. Their purpose is: Merge: copies properties from a transient entity to an eventually loaded entity with the same id in the first level cache; if there is no loaded entity with the same id, one will be loaded and placed in the first level cache first; if using version, the transient entity must have the same version as in the database; Persist: similar to Save or SaveOrUpdate, attaches a maybe new entity to the session, but does not generate an INSERT or UPDATE immediately and thus the entity does not get a database-generated id, it will only get it at flush time; Replicate: copies an instance from one session to another session, perhaps from a different session factory; SaveOrUpdateCopy: attaches a transient entity to the session and tries to save it. Here are some samples of its use. ISession session = ...; AuthorDetails existingDetails = session.Get<AuthorDetails>(1); //loads an entity and places it in the first level cache AuthorDetails detachedDetails = new AuthorDetails { ID = existingDetails.ID, Name = "Changed Name" }; //a detached entity with the same ID as the existing one Object mergedDetails = session.Merge(detachedDetails); //merges the Name property from the detached entity into the existing one; the detached entity does not get attached session.Flush(); //saves the existingDetails entity, since it is now dirty, due to the change in the Name property AuthorDetails details = ...; ISession session = ...; session.Persist(details); //details.ID is still 0 session.Flush(); //saves the details entity now and fetches its id ISessionFactory factory1 = ...; ISessionFactory factory2 = ...; ISession session1 = factory1.OpenSession(); ISession session2 = factory2.OpenSession(); AuthorDetails existingDetails = session1.Get<AuthorDetails>(1); //loads an entity session2.Replicate(existingDetails, ReplicationMode.Overwrite); //saves it into another session, overwriting any possibly existing one with the same id; other options are Ignore, where any existing record with the same id is left untouched, Exception, where an exception is thrown if there is a record with the same id and LatestVersion, where the latest version wins SyntaxHighlighter.config.clipboardSwf = 'http://alexgorbatchev.com/pub/sh/2.0.320/scripts/clipboard.swf'; SyntaxHighlighter.brushes.CSharp.aliases = ['c#', 'c-sharp', 'csharp']; SyntaxHighlighter.all();

    Read the article

  • How to generate SPMetal for a specific list (OOTB: like tasks or contacts) with custom columns

    - by KunaalKapoor
    SPMetal is used to make use of LINQ on a list in SharePoint 2010. By default when you generate SPMetal on a site you will get a code generated file for most of the lists and probably more. Here is a MSDN link for some info on SPMetal.http://msdn.microsoft.com/en-us/library/ee538255(office.14).aspxBut what if you want only to generate the code for one list?Well it is quite simple once you figure it out. You need to add an xml file to override the default settings of SPMetal and specify it in the /parameters option. I will show you how to do this.First create a Folder that will contain two files (GenerateSPMetalCode.bat and SPMetal.xml).Below is the content of the files:GenerateSPMetalCode.bat "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\SPMetal" /web:http://YourServer /code:OutPutFileName.cs /language:csharp /parameters:SPMetal.xml pause SPMetal.xml <?xml version="1.0" encoding="utf-8"?> <Web AccessModifier="Internal" xmlns="http://schemas.microsoft.com/SharePoint/2009/spmetal"> <List Name="ListName"> <ContentType Name="ContentTypeName" Class="GeneratedClassName" /> </List> <ExcludeOtherLists></ExcludeOtherLists> </Web> You will have to change some of the text in the files so that it will be specific to your SharePoint Server Setup. In the bat file you will have to change http://YourServer to the url of the web where your list is. In the SPMetal.xml file you need to change ListName to the name of your list and the ContentTypeName to the name of the content type you want to extract. The GeneratedClassName can be anything but perhaps you should rename it to something more sensible.Adding the following line: '<List Name="ListName"><ContentType Name="ContentTypeName" Class="GeneratedClassName" /> </List>'  makes sure that any custom columns added to an OOTB list like contacts or tasks are also generated, which are missed out in a regular generation.So now when you run it the SPMetal command will read the SPMetal.xml list and override its commands. ExcludeOtherLists element makes it so that only the code for the lists you specify will be generated. For some reason I got an error if I had this element above the List element.You sould now have a code file called OutPutFileName.cs that has been generated. You can now put this in your SharePoint project for use with your LINQ queries against that list.I will soon write a LINQ example that uses the generated class. UPDATE: Add the /namespace parameter to add a namespace to the generated code. "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\SPMetal" /web:http://YourServer /namespace:MySPMetalNameSpace /code:OutPutFileName.cs /language:csharp /parameters:SPMetal.xml

    Read the article

  • Issues with ASP.NET via Apache/mod_mono on Ubuntu.

    - by Matthew Scharley
    I run an Ubuntu test server, and my deployment system is also Ubuntu. I've recently been trying to get ASP.NET to work on my test server so that we can take it live. I managed to get it installed, and configured properly, and my application is installed and running, but I can't get anything to work. The error I keep receiving is below, if anyone has any clue what might be going on, it would be greatly appreciated. Server Error in '/' Application Standard output has not been redirected or process has not been started. Description: HTTP 500. Error processing request. Stack Trace: System.InvalidOperationException: Standard output has not been redirected or process has not been started. at System.Diagnostics.Process.CancelErrorRead () [0x00000] at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:CancelErrorRead () at Mono.CSharp.CSharpCodeCompiler.CompileFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at Mono.CSharp.CSharpCodeCompiler.CompileAssemblyFromFileBatch (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at System.CodeDom.Compiler.CodeDomProvider.CompileAssemblyFromFile (System.CodeDom.Compiler.CompilerParameters options, System.String[] fileNames) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath, System.CodeDom.Compiler.CompilerParameters options) [0x00000] at System.Web.Compilation.AssemblyBuilder.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.BuildAssembly (System.Web.VirtualPath virtualPath) [0x00000] at System.Web.Compilation.BuildManager.GetCompiledType (System.String virtualPath) [0x00000] at System.Web.HttpApplicationFactory.InitType (System.Web.HttpContext context) [0x00000] Version information: Mono Version: 2.0.50727.42; ASP.NET Version: 2.0.50727.42 Apache version String: Apache/2.2.11 (Ubuntu) mod_mono/2.0 PHP/5.2.6-3ubuntu4.2 with Suhosin-Patch Server at dev Port 80 PS: I had to add three DLL's to the /bin directory in my application, copying them from Windows because I couldn't find them in any of Mono's packages. This might or might not be causing problems, I don't know. The list that I had to add is: System.Web.Abstractions System.Web.Routing System.Web.Mvc

    Read the article

< Previous Page | 9 10 11 12 13 14 15 16 17 18 19 20  | Next Page >